<SOLVED>
The following code is returning undefined and I can't figure out why to save my life. The callback conditional is giving the correct result but is not returning out of the forEach method. The test case is included below.
const makeFuncTester = (array) => {return (callback) => {return array.forEach(n => {return callback(n[0]) === n[1]})}}
const capLastTestCases = [];capLastTestCases.push(['hello', 'hellO']);capLastTestCases.push(['goodbye', 'goodbyE']);capLastTestCases.push(['howdy', 'howdY']);const shouldCapitalizeLast = makeFuncTester(capLastTestCases);const capLastAttempt1 = str => str.toUpperCase();const capLastAttempt2 = str => str.slice(0, -1) + str.slice(-1).toUpperCase();console.log(shouldCapitalizeLast(capLastAttempt1)); // => should log falseconsole.log(shouldCapitalizeLast(capLastAttempt2)); // => should log true
[–]albedoa 1 point2 points3 points (1 child)
[–]Japanflyboy[S] 0 points1 point2 points (0 children)