lascii_Array Solution Submission

What is your hint or solution suggestion?

function lascii(cFrom, cTo) {
  var cCMin = cFrom.charCodeAt(0), cCMax = cTo.charCodeAt(0), begin = cCMin, ascii_arr = [];

  while(begin <= cCMax) {
      ascii_arr.push(String.fromCharCode(begin) );
      begin++; 
  }
console.log(`Ascii Array is ${ascii_arr}.\n`);
 return ascii_arr;
}

Challenge: Generate lower case ASCII alphabet

Link to the challenge:

Hi @mlpfanatic903!

I have edited your post to blur out the solution for campers who have not worked on this problem yet.

If you post a full passing solution to a challenge please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Thanks!

1 Like

I’ll keep that in mind… Thank you

Hey @mlpfanatic903!

So I was corrected that for the guide submissions to use the [details][/details] tags.

So that was my bad. Sorry.

Keep up the great work!

Happy coding!

1 Like

Minor style suggestions

function lascii(cFrom, cTo) {
  const cFromInt = cFrom.charCodeAt(0), cToInt = cTo.charCodeAt(0), asciiArr = [];
  let current = cFromInt;

  while (current <= cToInt) {
    asciiArr.push(String.fromCharCode(current));
    current++; 
  }

  return asciiArr;
}
  • JavaScript tends to use camelCase, and most of your variable did so, so I swapped the asciiArr variable to camelCase
  • begin was changing rather than staying at the beginning, so I renamed it
  • use of const were able is preferable, and use of var is discouraged