var userinput = prompt("Hello. Please enter a statement and I will repeat the last word");
if(typeof userinput !== "string"){
console.log("This is not a string.");
}
I am a complete newb and I was just trying to make a simple script that repeats the last word of a statement that you enter. I added this safeguard so that if you don't enter a string, it will display a message, but whenever I test the code with a number, it just ignores this part and still executes the else statement which is the code that finds the last word. I don't understand why this safeguard won't work.
Would really appreciate some help. Thanks
var userinput = +prompt("Enter number")then enter number, notice+