How do you make your else statement do nothing?

if-statement, javascript

Solution

an `if` doesn't need an `else` always .. so remove it.

if(){ ...}
if(){ ...}
if(){ ...} 

is fine , but its adviced to use `switch` in this case.

`switch` works better in this kind of situation

Problem

I'm new to programming in JavaScript, and I need help! I am making a small program that randomly selects a number (1-4) and then prints out a statement based on the number. A=1, 2=B, 3=C, and 4=D. My problem is that with my if/else statements, I want the else statement to do nothing. How? (Sorry if this is a dumb question, I'm new to JS) The code is: ``` var randomGuess=Math.floor(Math.random()*4)+1); if (randomGuess===1) { document.write("Try A."); } else { return false } if (randomGuess===2) { document.write("Try B.") } else { return false } if (randomGuess===3) { document.write("Try C.") } else { return false } if (randomGuess===4) { document.write("Try D.") } else { return false } ```

Original source