Skip to content

Instantly share code, notes, and snippets.

@mmloveaa
Created January 4, 2016 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmloveaa/7815f4f931da1d74cad0 to your computer and use it in GitHub Desktop.
Save mmloveaa/7815f4f931da1d74cad0 to your computer and use it in GitHub Desktop.
get ascii value of character
// 1/4/2016
// get ascii value of character
// write a function getASCII which inputs a character and returns the corresponding
// ascii value for that character. Example : getASCII('A') => 65
// for ASCII table, you can refer to http://www.asciitable.com/
// Test.assertEquals(getASCII('A'),65)
// Test.assertEquals(getASCII(' '),32)
// Test.assertEquals(getASCII('!'),33)
function getASCII(c){
return c.charCodeAt(0);
}
getASCII('!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment