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 118 views
1 answer 125 views
1 answer 105 views
1 answer 104 views
2 answers 193 views
1 answer 139 views
...