Wednesday, February 24, 2016

#javascript "Unexpected token :"

Problem
This is giving me the error "Unexpected token :", and all the : in the {} have a red sqiggly line

function buildObj(a, b){

return{ 
    "a":a,
    "b":b

}
}

Solution

Just move the { to the same line as return. For some reason this matters.

function buildObj(a, b){

return { 
    "a":a,
    "b":b

}
}

No comments:

Post a Comment

There was an error in this gadget