Rewrite the following code using conditional operator. Run it and submit th code example
Example 1: javascript function that make a choice
function computerplay() {
choices = ["rock", "paper", "scissors"]
var ai = choices[Math.floor(Math.random() * choices.length)]
return ai;
}
Example 2: ternary function javascript
var variable;
if (condition)
variable = "something";
else
variable = "something else";
//is the same as:
var variable = condition ? "something" : "something else";