Hi, I have typed a code for the chunky monkey algorithm.
I used my code with Virtual Studio Code and it worked, but it did not with freeCode camp and would like for someone to give me a hint as to why might it be incorrect when trying it out in freeCode Camp.
This is the code (I used array “a” as an example):
let a=["a", "b", "c", "d", "e"]
function splitting(array,size) {
b=[];
let n=array.length/size;
for (i=0; i<n; i++){
b.push(array.splice(0,size));
}
return b;
}
Thank you in advance for any help I can get.
I don’t think you can use html tags in the javascript curriculum.
I did not use the tags for the freeCode Camp site, sorry that I made it seem that way, I will make the edit. I used everthing in between those two tags but had no luck, it says it is incorrect.
Hello @YeisonQuiceno!
One thing I would recommend when using the Free Code Camp is to use console.log()
to test your code for errors; this has helped me see my mistakes many times while progressing through the program. It can be especially helpful if you put the function call within a console.log()
to see exactly what the output is.
Currently, when I try your code in the lesson console, the output is an error of ChunkArrayInGroups() is not a function
. This means that the function call in the problem is not finding the function you’ve written.
Hope this helps!
1 Like
Also, you’ll want to make sure you declare all of your variables.
2 Likes
No problem. In that case, you need to declare your variables. Everything else looks fine though.
1 Like