When I run this snippet, I get "4" as an output, but I want to return the value "4", 5 times.
Why is this and how can I fix it?
function addTwo(num){
return num + 2;
}
function checkConsistentOutput(func, val){
let first = func(val);
let second = func(val);
if(first === second){
for(let i = 0; i < 5; i++){
return first;
}
}else{
console.log("This function returned inconsistent results");
}
}
console.log(checkConsistentOutput(addTwo, 2));