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.
HTML Code :
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<script src="//jashkenas.github.io/coffee-script/extras/coffee-script.js"></script>
<title>Returns a passed string with letters in alphabetical order</title>
</head>
<body>
</body>
</html>
CoffeeScript Code :
alphabet_order = (str) ->
str.split('').sort().join ''
console.log alphabet_order('webmaster')
Sample Output:
"abeemrstw"
Live Demo :
See the Pen coffeescript-exercise-11 by w3resource (@w3resource) on CodePen.
Improve this sample solution and post your code through Disqus.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework