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>
<meta charset=utf-8 />
<title>JS Bin</title>

CoffeeScript Code :

function reverse_a_number(n)
	n = n + "";
	return n.split("").reverse().join("");

Live Demo :

JS Bin on jsbin.com

Post your code through Disqus :

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