需要大神用javascript 写一个代码。十万火急 javascript 高手进

需要大神用javascript写一个代码。十万火急//Challenge6//Thecodebelowpicksarandomnumberbetween1and10and... 需要大神用javascript 写一个代码。十万火急
//Challenge 6
//The code below picks a random number between 1 and 10 and stores it in the variable randomNumber. Prompt the user to enter a number. If the number is equal to the randomNumber, alert "Yes! The correct number is X" where X is the value of randomNumber. Otherwise, print out "Sorry, the correct number was X", where X is the value of randomNumber.
var randomNumber = Math.round(Math.random()*10)+1;
var guess = parseInt(prompt("Enter a number between 1 and 10"));

//Challenge 7
//Ask the user how many days it has been since playing basketball. If the response is less than 2, print 'You're a basketball enthusiast!' If the response is between 2 and 5, print 'You only sometimes play basketball'. If the response is more than 5, print 'You must not enjoy basketball at all.'
展开
 我来答
风铃冷冷2
2014-10-13 · TA获得超过1799个赞
知道小有建树答主
回答量:833
采纳率:0%
帮助的人:506万
展开全部
if(guess === randomNumber) {
    alert("Yes! The correct number is " + guess);
}
else {
    alert("Sorry, the correct number was " + randomNumber);
}

 

var s1 = "You're a basketball enthusiast!",
    s2 = 'You only sometimes play basketball',
    s3 = 'You must not enjoy basketball at all.';
var guess = parseInt(prompt("How many days it has been since playing basketball?"));

if (guess < 2) alert(s1);
if (guess >= 2 && guess <= 5) alert(s2);
if (guess > 5) alert(s3);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式