Skip to main content

Posts

Showing posts from May, 2015

CoderByte Array Addition I

I started playing around with coderbyte a place to test your programming skills. I was stumped for a bit on this question Array Addition I: "Using the JavaScript language, have the function  ArrayAdditionI( arr )  take the array of numbers stored in  arr  and return the string  true  if any combination of numbers in the array can be added up to equal the  largest number  in the array, otherwise return the string  false . For example: if  arr contains [4, 6, 23, 10, 1, 3] the output should return  true  because 4 + 6 + 10 + 3 = 23. The array will not be empty, will not contain all the same elements, and may contain negative numbers.  Use the  Parameter Testing  feature in the box below to test your code with different arguments." But eventually hammered it out. I saw some people using multiple for loops as well as nested loops. I took a different approach and just did math with the exception of one for loop. Here is my code example with assertions if you anyone is inte