Boolean() simply performs type conversion, it doesn't evaluate code. When converting a string to boolean, an empty string becomes false, a non-empty string becomes true.
If you want to evaluate the word, you have to call eval().
return s+" "+ Boolean(eval(s[1]));
Note that using eval() can be dangerous if the data comes from an untrusted source, since this will be able to execute any JavaScript functions.
When you type Boolean(1>3) in the console, 1>3 is evaluated as an expression by the console, it's not a string. To see the same problem in the console, enter Boolean("1>3"), since word is a string, not an expression that has already been evaluated.
wordand the wanted result.Boolean()will not evaluate the expression. Any non-empty string is true.Boolean("1>3")?1>3is not the same as"1>3". The console evaluates expressions.