Java Reference
In-Depth Information
Figure 10.3. Our test still fails
Oh dear, it still failed. This time, the failure message is a bit more specific. It says that it
was expecting the array [1,2,3,4,6,12] but received the array [1,2,3,4,6] ―the
last number 12 is missing. Looking at our code, this is because the loop only continues
while i < n . We need i to go all the way up to and including n , requiring just a small
tweak to our code:
src/numberCruncher.js (incomplete)
function factorsOf(n) {
var factors = [];
for (var i=1; i <= n ; i++) { // change on this line
Search WWH ::




Custom Search