countX("abcxxxbcdxx") returns 5
For this exercise, you may assume that words are separated by single spaces.
For example,
wordCount("This is a test of whether the test is a good test") returns { This: 1, is: 2, a: 2, test: 3, of: 1, whether: 1, the: 1, good: 1 }
class Foo { constructor(callback) { this.callback = callback; } doSomething(value){ this.callback(value + 5); } }Initialize f to be an object of class Foo. When you call:
f.doSomething(3);it should print 8 to the console.
class Bar extends Foo { constructor(callback, multiplier) { should call Foo's constructor and save multiplier } doSomething(value) { Should return Foo's doSomething(value * saved multiplier) } }Initialize b to be an object of class Bar with multiplier 3. When you call:
b.doSomething(3);it should print 14 to the console.