-
-
Save shridharkalagi/aa427250796a18eb3eed9f4517cfa9ac to your computer and use it in GitHub Desktop.
Javascript generate alphabet string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateAlphabets() { | |
var alphabets = []; | |
var start = 'A'.charCodeAt(0); | |
var last = 'Z'.charCodeAt(0); | |
for (var i = start; i <= last; ++i) { | |
alphabets.push(String.fromCharCode(i)); | |
} | |
return alphabets.join(''); | |
} |
Removing join will return an array
https://ariya.io/2013/07/sequences-using-javascript-array //For reference
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Array.apply(undefined, Array(26)).map(function(x,y) { return String.fromCharCode(y + 65); }).join('');