본문 바로가기
알고리즘/Codewars

[Codewars] Find the position! (8 kyu) / JavaScript

by fluss 2023. 3. 19.

https://www.codewars.com/kata/5808e2006b65bff35500008f

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

When provided with a letter, return its position in the alphabet.

Input :: "a"

Ouput :: "Position of alphabet: 1"

 

코드

function position(letter){
  return `Position of alphabet: ${letter.charCodeAt(0) - 96}`;
}

댓글