w3resource logo

CoffeeScript exercises

CoffeeScript function: Returns a passed string with letters in alphabetical order

CoffeeScript Function : Exercise-11 with Solution

Write a CoffeeScript function that returns a passed string with letters in alphabetical order.

Example string : 'webmaster'
Expected Output : 'abeemrstw'

Note: Assume punctuation and numbers symbols are not included in the passed string.

Solution :

HTML Code :

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

CoffeeScript Code :

alphabet_order = (str) ->
  str.split('').sort().join ''

alert alphabet_order('webmaster')

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:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number