Back to Freecodecamp

Challenge 167: Bingo! Letter

curriculum/challenges/english/blocks/daily-coding-challenges-javascript/696655d24b614176d4c9b78a.md

latest1.1 KB
Original Source

--description--

Given a number, return the bingo letter associated with it (capitalized). Bingo numbers are grouped as follows:

LetterNumber Range
"B"1-15
"I"16-30
"N"31-45
"G"46-60
"O"61-75

--hints--

getBingoLetter(75) should return "O".

js
assert.equal(getBingoLetter(75), "O");

getBingoLetter(54) should return "G".

js
assert.equal(getBingoLetter(54), "G");

getBingoLetter(25) should return "I".

js
assert.equal(getBingoLetter(25), "I");

getBingoLetter(38) should return "N".

js
assert.equal(getBingoLetter(38), "N");

getBingoLetter(11) should return "B".

js
assert.equal(getBingoLetter(11), "B");

--seed--

--seed-contents--

js
function getBingoLetter(n) {

  return n;
}

--solutions--

js
function getBingoLetter(n) {
  if (n >= 1 && n <= 15) return "B";
  if (n >= 16 && n <= 30) return "I";
  if (n >= 31 && n <= 45) return "N";
  if (n >= 46 && n <= 60) return "G";
  if (n >= 61 && n <= 75) return "O";
  return null;
}