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.

Solve these problems:

Python: How to check whether a file exists using Python?

C#: Loops in c#

PHP: For each

SQL: JOIN using more than 5 tables

JavaScript: Blank Slide in Javascript Slideshow