Pages

Sunday, June 19, 2016

Coding challenge

Hint : Use an underscore function.

Make all of the even numbers in an array odd, and then return the array with all odd numbers. Make each even number odd by adding 1.


For example,

var array1 = [2,5,7,6,5,8,9]

output should be : [3,5,7,7,5,9,9]
Solution in the comments.  



1 comment:

  1. var example = _.map(array1, function(item){
    if(item % 2 === 0){
    return item + 1;
    }
    else{
    return item;
    }
    });

    ReplyDelete