Code Fight

Challenge 1

Write a JavaScript function to generate a random integer.

ex:

 rand(2,5) => posible value: 2,3,4,5;

 rand(10, 12) => posible value: 10, 11, 12

Challenge 2

Write a JavaScript function to get the greatest common divisor (gcd) of two integers.

ex:

.  gcd(8, 12) = 4

.  gcd(12, 14) = 2

Challenge 3

Write a JavaScript function to get the least common multiple (LCM) of more than 2 integers.

ex:

.  lcm(3, 4) = 12

.  lcm(8, 12) = 24

Final Challenge

Given an array of integer values find the mode of the given data. Mode is the value that appears in the array maximum number of times. If there are two or more mode elements appearing the same number of times then return all of them in an array.
The mode elements should be returned in the same order they appear in the original array.

Example:

For a = [555, 123, 334, 233, 123, 555, 444, 567, 334] the output should be [555, 123, 334].

For a = [1, 2, 3, 4, 5, 6, 100, 200, 100] The output should be [100]

For a = [10, 20, 30, 40, 22, 22, 33, 33, 33] The output should be [33]

deck

By Quy Tran