3 minutes, 18 seconds :)
*kuch* nerd *kuch* haha ;-) Ik verspeelde veel tijd met odd/even ;-)
Ik zat wel even te prutten bij de length van een chineese string :)
'T was ook echt niet hele mooie code moet ik toegeven... maar het werkte :)

function doubleInteger(i) {
    // i will be an integer. Double it and return it.

    return i * 2;  
}



function isNumberEven(i) {
    // i will be an integer. Return true if it's even, and false if it isn't.
    
    return i % 2 ? false : true;
}



function getFileExtension(i) {
    // i will be a string, but it may not have a file extension.
    // return the file extension (with no period) if it has one, otherwise false
    
    if (-1 == i.indexOf('.')) {
        return false;
    }
    
    var parts = i.split('.');
    
    return parts[parts.length - 1]; 
}



function longestString(i) {
    // i will be an array.
    // return the longest string in the array
    
    var value = '';
    
    for (var ii = 0; ii <= i.length; ii++) {
        if (typeof i[ii] == 'string' && i[ii].length >= value.length) {
            value = i[ii];
        }
    }
    
    return value;
}



function arraySum(i) {
    // i will be an array, containing integers, strings and/or arrays like itself.
    // Sum all the integers you find, anywhere in the nest of arrays.
    
    var sum = 0;
    
    for (var ii = 0; ii <= i.length; ii++) {
        if (typeof i[ii] == 'number') {
            sum += i[ii];
        } else if (typeof i[ii] == 'object') {
            sum += arraySum(i[ii]);
        }
    }
    
    return sum;
}


Benieuwd hoe jij het hebt opgelost Wouter ;-)
function doubleInteger(i) {
    // i will be an integer. Double it and return it.

    i *= 2;

    return i;  
}

function isNumberEven(i) {
    // i will be an integer. Return true if it's even, and false if it isn't.
    
    return i % 2 === 0;
}

function getFileExtension(i) {
    // i will be a string, but it may not have a file extension.
    // return the file extension (with no period) if it has one, otherwise false
    
    return i.split('.')[1] || false;
}

function longestString(i) {
    // i will be an array.
    // return the longest string in the array
    
    var longest = 0;
    var string;
    i.forEach(function (ie) {
        if (typeof ie !== 'string') {
            return;
        }

        var len = 0;
        while(ie.charAt(++len) !== '');

        if (len > longest) {
            string = ie;
            longest = len;
        }
    });

    return string;
}

function arraySum(i) {
    // i will be an array, containing integers, strings and/or arrays like itself.
    // Sum all the integers you find, anywhere in the nest of arrays.
    
    var sum = 0;
    
    i.forEach(function (ie) {
        switch (typeof ie) {
            case 'number':
                sum += ie;
                break;

            case 'object':
                sum += arraySum(ie);
                break;
        }
    });
    
    return sum;
}


[size=xsmall]Toevoeging op 08/11/2013 11:55:43:[/size]

Hertog of Jan, hoe kan jouw longestString functie goed hebben gewerkt? Bij mij werkte die niet bij chineese tekens.

function isNumberEven(i) {
    // i will be an integer. Return true if it's even, and false if it isn't.
    
    return i % 2 == 0;
} 

Is volgens mij korter :)

Reageren