Files
freeCodeCamp/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/69f35a5bb823ed620fcb7cba.md
T

1.8 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69f35a5bb823ed620fcb7cba Challenge 281: Bingo Range 28 challenge-281

--description--

Given a bingo letter, return the number range associated with that letter.

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

Return an array with all numbers in the range from smallest to largest.

--hints--

getBingoRange("B") should return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15].

assert.deepEqual(getBingoRange("B"), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);

getBingoRange("I") should return [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30].

assert.deepEqual(getBingoRange("I"), [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]);

getBingoRange("N") should return [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45].

assert.deepEqual(getBingoRange("N"), [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]);

getBingoRange("G") should return [46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60].

assert.deepEqual(getBingoRange("G"), [46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]);

getBingoRange("O") should return [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75].

assert.deepEqual(getBingoRange("O"), [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75]);

--seed--

--seed-contents--

function getBingoRange(letter) {

  return letter;
}

--solutions--

function getBingoRange(letter) {
  const ranges = { B: [1, 15], I: [16, 30], N: [31, 45], G: [46, 60], O: [61, 75] };
  const [start, end] = ranges[letter];
  return Array.from({ length: end - start + 1 }, (_, i) => start + i);
}