Hi everyone,
I’m a beginner, don’t blame me if I’m wrong, but I think something could be wrong in the ‘task 4’ of the exercise called ‘Lasagna Master’. This is the function:
export function addSecretIngredient(friendList, myList){
myList.push(friendList[friendList.length -1])
}
but if you pass this ’ myList.push(‘undefined’) ', you can get 2 of 3 tests passed. And if you pass this ’ myList.push(‘marjoram’) ’ you can get all the 3 tests passed.
Yes. All three of those tests are using the same data, but testing different properties:
describe('addSecretIngredient', () => {
test('adds the secret ingredient to the second array', () => {...},
test('does not modify the first array', () => {...},
test('does not return anything', () => {...}
}
All three tests use the same data and have the same secret ingredient. Yes, this means you can hard code the results. The tests, when they all pass, indicate this function is probably implemented correctly. Having one test pass with incorrect code is not a “problem”.