+ 3
Javascript
Which century? The editor is empty? https://www.sololearn.com/post/1773448/?ref=app
16 odpowiedzi
+ 6
The code coach seems broken for me.
I already completed this some time ago and it has a green checkmark on it, but when I ran it today, everything is 'no output'. But my code is still there. Something is broken on Sololearn's end.
The code without my solution:
function main() {
var year = parseInt(readLine(), 10)
// output
console.log(calcCent(year));
}
// complete the code
function calcCent(year){
// your code here
}
+ 10
You must write the code to 1) take the year as input from the console, 2) process it, and 3) output the century.
Then press RUN to execute the tests and see the results. Code Coach supplies the input values to the console automatically.
+ 3
do not call main() – this is handled by sololearn.
you seem to use an old course. you can try to reset the code and see if the template code appears.
+ 3
when you reset the course progress, the most recent course version should be loaded.
if you do not plan to reset the course, try to reset the code.
+ 3
i do not find this code project in my course version.
+ 3
Okay, I found it! It's empty for me, too.
+ 3
write to info@sololearn.com
+ 3
doesn't help
+ 1
Brian
function main(year) {
var calcCent = Math.ceil(year / 100);
console.log(calcCent);
}
var year = parseInt(readLine(), 10)
main(year)
This is my code but when I run it, it shows no output?
+ 1
Lisa No, I have js intermediate.Old courses are removed
+ 1
Lisa I reset the code, but still doesn't working.
+ 1
Lisa In the lesson 'The math object'.
+ 1
The code you wrote has a few minor issues. Try this:
function calcCentury() {
return Math.ceil(year / 100);
}
var year = parseInt(prompt(), 10)
var century = calcCentury(year)
console.log(century)
Issue #1: You shouldn't name a function main(). Bad form. Give the function a purpose and name it accordingly.
Issue #2: You used readLine(). That wasn't working. I used prompt() instead. That was your main issue for why it wasn't working.
0
How to solve it now, when we try to take input from user using parseInt(readLine(), 10); Still it doesn't work.