Need a review for my code.Thanks :)

I completed this challenge on my own and i want someone to review my code.I noticed that i solved all the challenges in a different way than the forum solutions,most of the times with more lines of code and it makes me feel bad cause i know you have to optimize your code as much as possible, but this is how think what can i do for it?
Anyway check the code i created for the last challenge,i am pretty sure that if you tell me some days from now to do it the same way i will not be able to do it like this :stuck_out_tongue: .Still i am very proud i completed the 95% of basic algorithms on my own.Thank you freeCodeCamp.

function chunkArrayInGroups(arr, size) {
let chunks =arr.length/size;
let array2=[];
for(let i=0;i<chunks;i++){
  array2[i]=arr.slice(i*size,(i*size)+size);
}

return array2;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

As @ArielLeslie is right, you will precede it and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

For example with backtick between the text:
freeCodeCamp is the best!

And 3 backticks between the text:

// Paste codes here.

Thanks!
Pummarin :smiley: