0
Wich century in Javascript..
Hey there! so the excercise is: Create a function that returns the century depending on the year given as a parameter. Sample Input 1993 Sample Output 20 Hint You need to divide 1993 by 100: 1993/100 = 19.93, then round it to the nearest integer, which is 20 in this case. I made: function main() { var x = parseInt(readLine(), 10) //the output console.log(calcCent(x)); } //complete the function function calcCent(x){ console.log(Math.ceil(x/100));} Wich returns 18 Undefined.. And i am not sure where the undefined is coming from! Thanks in advance for any help i can get!
2 Respuestas
+ 4
If anyone wants to know why it prints 'undefined' because the function doesn't return a value at the end. With console.log() inside a function, you don't need the outside one.
return Math.ceil(x/100)
+ 3
After looking at it for a couple minutes more i realised my mistake!
Sorry for taking time out of everyone their day! and thank you again incase you wanted to help!