create alphabet array in js

QuestionsCategory: Javascriptcreate alphabet array in js
VR Soft Coder Staff asked 4 months ago

How can we create alphabet array in js

1 Answers
Best Answer
VR Soft Coder Staff answered 4 months ago
var alpha_bet = "abcdefghijklmnopqrstuvwxyz".split("");

// Output ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
var alpha_bet = [...Array(26)].map((v,i)=>v=String.fromCharCode(i+97));

// Output ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

Your Answer

Related Posts

Begin typing your search above and press enter to search. Press ESC to cancel.

Back To Top