gpt4 book ai didi

javascript - 如何将此 python 代码转换为 Javascript

转载 作者:行者123 更新时间:2023-12-03 04:41:09 24 4
gpt4 key购买 nike

我不想在Javascript中运行Python代码,我想将它完全变成JS代码。我对Python一无所知,Can body可以帮助我解决这个问题。谢谢。

print ("Please input the # of books you've read this year") 
BooksAlready=int(input())
print ("Please input the # of weeks that have already passed this year")
WeeksAlready=int(input())
x=(78/52)
c=x*WeeksAlready-BooksAlready
if (BooksAlready/WeeksAlready)>x:
print ("You're on point, go have some fun!")
else:
print ("Go read, you piece of uneducated crap")
print ("You have")
print (c)
print ("books left to read this week to get on point")

最佳答案

这将在浏览器的 js 控制台中运行。 prompt 在 Node.js 中不起作用,您可以使用 process.argv 访问命令行参数。

console.log("Please input the # of books you've read this year");
console.log("Please input the # of weeks that have already passed this year");

var WeeksAlready=parseInt(prompt()),
BooksAlready=parseInt(prompt()),
x=(78/52),
c=x*WeeksAlready-BooksAlready;

if (BooksAlready/WeeksAlready>x){
console.log("You're on point, go have some fun!");
}
else{
console.log ("Go read, you piece of uneducated crap");
console.log ("You have");
console.log (c);
console.log ("books left to read this week to get on point");
}

关于javascript - 如何将此 python 代码转换为 Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43084513/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com