-1

I´m getting an Uncaught SyntaxError: Unexpected identifier error in Google chrome when executing this code. I want to calculate the number of values in edades that are between min and `max.

function edades(int min, int max){

    var edades = [22,27,29];

    var num=0; 

    var i;

    for (i = 0; i < edades.length; i++) {
        if(min<=edades[i] && edades[i]<=max){
            num++;
        }
    }

    return num;
}//edades

1 Answer 1

0

Remove the int type from the function arguments:

function edades(min, max){

    var edades = [22,27,29];

    var num=0; 

    var i;

    for (i = 0; i < edades.length; i++) {
        if(min<=edades[i] && edades[i]<=max){
            num++;
        }
    }

    return num;
}//edades
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.