How to increment letters in JavaScript

1 Answer

0 votes
function nextChar(char) {
  	return String.fromCharCode(char.charCodeAt(0) + 1);
}

console.log(nextChar('a')); 
console.log(nextChar('b')); 

console.log(nextChar('A')); 
console.log(nextChar('B')); 
  
  
  
  
  
/*
run:
  
"b"
"c"
"B"
"C"
  
*/

 



answered May 3, 2022 by avibootz

Related questions

1 answer 203 views
1 answer 215 views
1 answer 186 views
1 answer 196 views
2 answers 299 views
1 answer 217 views
...