So I’m trying to figure out how to use a window.prompt, and then if the user answers “yes”, to have an image printed on our page. Currently the script looks like this:
var answer
answer = window.prompt("Do you like google?");
if(answer=="yes") {
// print an image
}
else if(answer=="no") {
window.alert("no")
}
else {
window.alert("invalid")
}
Is there a way to get it to print in the body of the page? Also as a side question, is there a way to make the answer non-case sensitive, or if I’m using if/else statements would I have to use a + operator to account for capitalization.
anyway, look up toLowerCase and toUpperCasemethods
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.