How can I console.log() the following function:
function checkPalindrome(inputString) {
let j = inputString.length;
for (let i = 0; i<j/2; i++){
if(inputString[i] != inputString[j-1-i])
return false;
}
return true;
}
For example, I want to find out what the computer is spitting out if I console.log the for loop.
You can’t console.log
the for-loop, but you can do that for the values in the for-loop.
for (let i = 0; i < j / 2; i++) {
// You can print individual values
console.log(inputString[i]);
console.log(inputString[j - 1 - i]);
// You can also print more complex expressions
console.log(inputString[i] != inputString[j - 1 - i]);
...
}
Those just tell me that “j” isn’t defined.
Your code above has it though. DId you remove it somehow?
Nevermind, it tells me inputString is not defined.