Find numbers that are divisible by a given number
Complete a function that takes two arguments and returns all numbers that are divisible by the given divisor. The first argument is an array of numbers and the second is a divisor.
divisibleBy([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]
See the answer only if you could not solve the problem yourself.
Twice as old
Your function takes two arguments:
- father's current age (years)
- the current age of the son (years)
Calculate how many years ago a father was twice as old as his son, or in how many years he will be twice as old.
Count odd numbers below
n is given, return the number of positive odd numbers less than
oddCount(7) //=> 3, i.e [1, 3, 5]
oddCount(15) //=> 7, i.e [1, 3, 5, 7, 9, 11, 13]
Convert string to number!
We need a function that can convert a string to a number. What ways do you know to achieve this?
Note: Don't worry, all inputs will be strings, and each string is a perfectly valid integer representation.
stringToNumber('1234') == 1234
stringToNumber('605') == 605
stringToNumber('1405') == 1405
stringToNumber('-7') == -7
The entire video playlist on this topic can be viewed on our YouTube channel.
On the tatami at Codewars, put on a kimono.