Quotes help make search much faster. Example: "Practice Makes Perfect"

Friday, December 7, 2012

LearnStreet Javascript Lesson 7 Exercise 2


//sample solution


function everyOther(arr) {
    //your code here
    var index = 0;
    var arrLength = arr.length;
    var sum = 0;
    for(index=0;index<arrLength;index+=2){
        sum+=arr[index];
    }
    return sum;
}
//test
everyOther([1,2,3,4]);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts