How to complete this code?

confirm("I am ready to play!")

var age=prompt("What is your age?")

if(age<18){console.log("You're allowed to play,but I take no responsibility.")}

else{console.log("Enjoy yourself!")}

console.log("Snow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him.")

console.log("Batman glares at you.")

var userAnswer=prompt("Are you feeling lucky,punk?")

if(userAnswer==="yes"){console.log("Batman hits you vary hard.It's Batman and you're you!Of course Batman wins!")}

else{console.log("You did not say yes to feeling lucky.Good choise!You are a winner in the game of not getting beaten up by Batman.")}

The code is written in Javascript.

How can I put in the "no" option?

2 Answers

Rating
  • 6 years ago
    Favorite Answer

    Example:

    if(userAnswer==="yes"){

    ...

    }else if(userAnswer==="no"){

    ...

    }else{

    ...

    }

  • 6 years ago

    昨天我本來 也是 像 你這樣寫的

    不過 看到 他 後面的 else 就刪掉了 總覺得 他這個 難道不能 已經代表 no 這個東西了嗎 ?

    2014-01-29 11:33:27 補充:

    啊 沒錯 再看一次 想一下的話

    在他這個程式意義的邏輯上 只有 yes 跟 no 還可以加 上 第三個以上的條件

Still have questions? Get your answers by asking now.