In Computer programming, a loop can be defined as a sequence of instructions that are executed repeatedly until a specific condition is true or for a certain number of times.
This ultimately implies that, a loop is a programming structure that continually repeats a sequence of instructions until a specific condition is true (met) or for a definite number of times.
Basically, there are three (3) main types of loop in programming and these includes;
I. For loop.
II. While loop.
III. Repeat.
Since loops continually repeats a sequence of instructions until a specific condition is true (met), it is a best practice to ensure that the loop breaks at some point to avoid an infinite loop. An infinite loop typically causes a software program to crash.
Thus, the break command is used by programmers to prevent an infinite loop or terminate a current loop immediately.
Hence, the command to get out of the loop is break.
If(new Dog.name===this.name,new Dog.age===this.age, new Dog.healthScores===this.healthScores){return true;
}
else{
console.log("objects are not equal");
}
}
}
To call the method checkObject:
var Tesa = new Dog(Tes,1,[45,46,82]);
var Bingo = new Dog(bing,2,[43,46,82]);
Bingo.checkObject(Tesa);
Note: we have used ES6(latest version of Javascript) where we passed the healthScore parameter(which is an array) to our constructor using the spread operator.