JavaScript ceil() method implementation

Took 1 minute and 16 seconds to code JavaScript ceil() method. Here is the code snippet.

Code:

num = 4.4;
function ceil(num) {
x = num;
x = x - x % 1;
x = x + 1;
return x;
}

document.write(ceil(num));

Result:

5

No comments:

Post a Comment

GITEX Dubai Talk by Saion Gupta and Saiasmi Gupta

Good morning, everyone. I'm Saion Gupta, the Founder of 10xCoderKids and the Guinness World Record holder for the youngest computer prog...