मुख्य कंटेंट तक स्किप करें

Theory is good, but without practice how to fly with one wing, so in this section we will solve problems in JavaScript. We took the tasks from the Codewars - site this is a site where you can improve your skills not only in JavaScript, but also in other programming languages.

## 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.

### Example​

``divisibleBy([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]``

### Practice​

लाइव एडिटर
परिणाम

See the answer only if you could not solve the problem yourself.

## Twice as old​

• 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`​

If number `n` is given, return the number of positive odd numbers less than `n`, EASY!

### Example​

``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.

### Example​

``stringToNumber('1234') == 1234stringToNumber('605') == 605stringToNumber('1405') == 1405stringToNumber('-7') == -7``

लाइव एडिटर
परिणाम