w3resource logo


CoffeeScript exercises

CoffeeScript function: Reverses a number

CoffeeScript Function : Exercise-9 with Solution

Write a CoffeeScript function that reverses a number.

Example x = 58973;
Expected Output : 37985

Solution :

HTML Code :

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
</body>
</html>

CoffeeScript Code :

function reverse_a_number(n)
{
	n = n + "";
	return n.split("").reverse().join("");
}
alert(reverse_a_number(32243));

Live Demo :

JS Bin on jsbin.com

Post your code through Disqus :



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program