Sorry if I've made mistakes writing this post. I'm new here and I don't know how this works, hope I learn quick. I am also new at JavaScript.
So the question is: I have this on my code.elements.js file and I can't make it work.
Does putting this work?
if (codePrompt == (codeSwitch || codeSwitchBG || codeBlur || codeShowInfo)){};
Or do I have to make it by the normal way?, like
if (codePrompt == codeSwitch || codePrompt == codeSwitchBG || codePrompt == codeBlur || codePrompt == codeShowInfo){};
var codeSwitch = 'switch()';
var codeSwitchBG = 'switch(background)';
var codeBlur = 'blur()';
var codeShowInfo = 'showInfo()';
$(".code").on("click", function () {
var codePrompt = prompt("Set the code in the command line.");
if (codePrompt == (codeSwitch || codeSwitchBG || codeBlur || codeShowInfo)) {
if (codePrompt == codeSwitch) {
alert("Switching background...");
console.log("Used '" + codeSwitch + "' command.");
} else if(codePrompt == codeBlur) {
alert("Blurring elements...");
console.log("Used '" + codeBlur + "' command.");
} else if(codePrompt == codeSwitchBG) {
alert("Switching background...");
console.log("Used '"+ codeSwitchBG + "' command.");
}else if(codePrompt == codeShowInfo) {
alert("Showing info...");
console.log("Used '"+ codeShowInfo + "' command.");
}
} else {
alert("Wrong command, try again.");
console.log("Wrong command, try again.");
};
});