+ 1
Why this code given error?
var value = 0; if(value){ return true; } else { return false; }
3 Antworten
+ 4
Romjan Ali
Return should be inside function
Break should be inside loop or switch
+ 1
var value = 0;
if(value){
console.log(true);
} else {
console.log(false);
}
+ 1
To return something you need a function. Above code will be like this,
var value=0;
function tf(){
if(value){return true}else{return false}
}
console.log(tf()) or simply call the function tf()