couple

Finished
44//
55
66/**
7 * @param {number} initialBottlesCount
8 * @param {number} takeDownCount
9 * @return {string[]}
7 * Recites the lyrics to '99 Bottles of Beer on the Wall' for a range of bottles.
8 *
9 * @param {number} initialBottlesCount - The starting number of bottles (0-99)
10 * @param {number} takeDownCount - How many verses to recite (default: 1)
11 * @return {string[]} - Array of lyrics lines
1012 */
1113export const recite = (initialBottlesCount, takeDownCount = 1) => {
12 throw new Error('Remove this line and implement the function');
14 // Edge Case: Invalid input types
15 if (typeof initialBottlesCount !== 'number' || typeof takeDownCount !== 'number') {
16 throw new Error('Both parameters must be numbers');
17 }
18
19 // Edge Case: Negative numbers
20 if (initialBottlesCount < 0 || takeDownCount < 0) {
21 throw new Error('Parameters must be non-negative');
22 }
23
24 // Edge Case: takeDownCount of 0
25 if (takeDownCount === 0) {
26 return [];
27 }
28
29 const result = [];
30
31 for (let i = 0; i < takeDownCount; i++) {
32 const currentBottles = initialBottlesCount - i;
33
34 // Edge Case: Going below 0 bottles
35 if (currentBottles < 0) {
36 break;
37 }
38
39 // Handle special cases for different bottle counts
40 if (currentBottles === 0) {
41 result.push('No more bottles of beer on the wall, no more bottles of beer.');
42 result.push('Go to the store and buy some more, 99 bottles of beer on the wall.');
43 } else if (currentBottles === 1) {
44 result.push('1 bottle of beer on the wall, 1 bottle of beer.');
45 result.push('Take it down and pass it around, no more bottles of beer on the wall.');
46 } else if (currentBottles === 2) {
47 result.push('2 bottles of beer on the wall, 2 bottles of beer.');
48 result.push('Take one down and pass it around, 1 bottle of beer on the wall.');
49 } else {
50 result.push(`${currentBottles} bottles of beer on the wall, ${currentBottles} bottles of beer.`);
51 result.push(`Take one down and pass it around, ${currentBottles - 1} bottles of beer on the wall.`);
52 }
53
54 // Add empty line between verses except after the last verse
55 if (i < takeDownCount - 1) {
56 result.push('');
57 }
58 }
59
60 return result;
1361};
62
63// Handled Edge Cases: Invalid input types, negative numbers, takeDownCount of 0, going below 0 bottles
Test NameStatus
first generic verse
Pass
last generic verse
Pass
verse with 2 bottles
Pass
verse with 1 bottle
Pass
verse with 0 bottles
Pass
first two verses
Pass
last three verses
Pass
all verses
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.