'Javascript Emoticon compared to other emoticons problem
I made a program that compares two values of emoticons and then returns another one as input. However, when I enter the correct emoticons, nothing happens. The emoticons look different in code and in real input. windows 10 emoticons.
function output(a) {
windows.alert(a);
}
emoticon1 = window.prompt("enter emoticon:");
emoticon2 = window.prompt("enter emoticon2");
if (emoticon1 === "☀" ) and (emoticon2 === "☁" ); {
output("⛅");
}
Thanks.
Solution 1:[1]
There's no operator called
and. It should be&&.There's no variable called
windows. It should bewindow, or simplyalert(a).Declare your variables properly.
Remove that extraneous semi-colon from the if statement.
function output(a) {
alert(a);
}
const emoticon1 = prompt('enter emoticon:');
const emoticon2 = prompt('enter emoticon2');
if (emoticon1 === '?' && emoticon2 === '?') {
output('?');
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andy |
