I don't want to run the Python code inside Javascript, I want to turn it completely into JS code. I have no idea about python, Can body can help me on this. Thank you.
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")
Cfreak
19.4k6 gold badges52 silver badges64 bronze badges
-
Presumably you want this to run in a terminal like NodeJS?Alexander Nied– Alexander Nied2017年03月29日 04:45:09 +00:00Commented Mar 29, 2017 at 4:45
-
1Possible duplicate of Python to Javascript converterHarsha W– Harsha W2017年03月29日 04:45:40 +00:00Commented Mar 29, 2017 at 4:45
-
1This might help you-stackoverflow.com/questions/22595989/…Mamun– Mamun2017年03月29日 04:47:20 +00:00Commented Mar 29, 2017 at 4:47
-
If you just need it to run in a JS environment, apparently some tools do exist -- although I'm a bit dubious of cross-language transpilation. Or is this an exercise-- where you want to do it to learn about Python?Alexander Nied– Alexander Nied2017年03月29日 04:47:50 +00:00Commented Mar 29, 2017 at 4:47
-
@anied yes I want to run this in JS environment. I want to convert into pure JsGold Pearl– Gold Pearl2017年03月29日 04:51:16 +00:00Commented Mar 29, 2017 at 4:51
2 Answers 2
This will run in the browser's js console. prompt will not work in node.js, you can access a commandline argument with 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");
}
Sign up to request clarification or add additional context in comments.
Comments
Please check below links to know more about converters from python to js.
answered Mar 29, 2017 at 4:55
Mohammed Rishad
3353 silver badges7 bronze badges
Comments
default