Tell us what’s happening:
Describe your issue in detail here.
Hello everyone,
Can i use nested loop to write
1 Outer loop and two inner loops? To make it clear, see the code below.
What i want to get from doing this is:
Comparing the elements of the two array, i want to be able to see if some element exist on the other array. I need to do it to complete some challenge, that’s why i can’t just type
Array1.indexOf(Array2[index]);
Because i have to create a code that any arguments can use.
const both = [[0, 1, 2, 3, 4],[0, 1, 2, 3]];
for (let B = 0; B < both.length; B = B + 1)
{ for (let R = 0; R < both[B].length; R = R + 1){
console.log(B, both[B]); } //
for (let S = 0; S < both[B].length; S = S + 1) {
console.log(S, “Yes”); }
Console.log(B, “END”); };
// for (let R…etc) refer to both[0]
// for (let S…etc) refer to both[1]
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15
Challenge Information:
Basic JavaScript - Nesting For Loops