Thursday, 24 December 2015

Kata Day 28: Number Pairs


Problem Description: In this Kata the aim is to compare each pair of integers from 2 arrays, and return a new array of large numbers.

Note: Both arrays have the same dimensions.

Example:

let arr1 = [13, 64, 15, 17, 88];
let arr2 = [23, 14, 53, 17, 80];
getLargerNumbers(arr1, arr2); // Returns [23, 64, 53, 17, 88]

Level:7kyu

Link to Kata: Number Pairs

It is a pretty easy Kata where we have to find maximum of two arrays at the same index. We initialize an empty array "ans". Then we loop from 0 to one less than the length of input array. Then we compare the element at the looping index from both the input arrays and then we push the bigger element to the "ans" array.

Once we are done looping through the array then we will return the "ans" array as our answer. 

Here is a link to the code: Kata Day 28

Please mention your suggestions or your doubts in the comment below.


Happy coding. :)

No comments:

Post a Comment