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

4 answers 177 views
1 answer 109 views
109 views asked May 3, 2022 by avibootz
1 answer 114 views
1 answer 127 views
1 answer 134 views
1 answer 112 views
...