diff --git a/curriculum/challenges/english/25-front-end-development/lab-lunch-picker-program/66db529d37ad966480ebb633.md b/curriculum/challenges/english/25-front-end-development/lab-lunch-picker-program/66db529d37ad966480ebb633.md index cd5d4fb19bb..cd1f1aef62a 100644 --- a/curriculum/challenges/english/25-front-end-development/lab-lunch-picker-program/66db529d37ad966480ebb633.md +++ b/curriculum/challenges/english/25-front-end-development/lab-lunch-picker-program/66db529d37ad966480ebb633.md @@ -307,29 +307,57 @@ const temp = console.log; try { console.log = obj => tempArr.push(obj); - // check that it correctly outputs the first item Math.random = () => 0; - getRandomLunch(testLunches); + getRandomLunch([...testLunches]); assert.strictEqual(tempArr[0], `Randomly selected lunch: ${testLunches[0]}`); - // second item + // Second item Math.random = () => 0.4; - getRandomLunch(testLunches); + getRandomLunch([...testLunches]); assert.strictEqual(tempArr[1], `Randomly selected lunch: ${testLunches[1]}`); - // third item + // Third item Math.random = () => 0.8; - getRandomLunch(testLunches); + getRandomLunch([...testLunches]); assert.strictEqual(tempArr[2], `Randomly selected lunch: ${testLunches[2]}`); } finally { - // restore Math.random Math.random = tempRandom; console.log = temp; } ``` +The `getRandomLunch` function should not change the array passed to it as argument. + +```js +const testLunches = ["Fish", "Fries", "Roast"]; +let originalLunches = [...testLunches]; +const tempRandom = Math.random; + +try { + Math.random = () => 0; + getRandomLunch(testLunches); + assert.sameOrderedMembers(testLunches, originalLunches); + + Math.random = () => 0.4; + getRandomLunch(testLunches); + assert.sameOrderedMembers(testLunches, originalLunches); + + Math.random = () => 0.8; + getRandomLunch(testLunches); + assert.sameOrderedMembers(testLunches, originalLunches); + + const emptyLunches = []; + let originalEmpty = [...emptyLunches]; + getRandomLunch(emptyLunches); + assert.sameOrderedMembers(emptyLunches, originalEmpty); + +} finally { + Math.random = tempRandom; +} +``` + You should define a function `showLunchMenu`. ```js