I have an object mobile_specs which have several fields such as DeviceName, Brand, Camera. I loop though the mobile_specs object so that i can print the specifications of two mobiles in tabular format:
var i=0;
Object.keys(mobile_specs).forEach(function(key) {
if(i==5)
{
break;
}
var mobile1=mobile_specs.[key];
var mobile2=mobile_specs.[key];
alert(mobile1 + " " +mobile2);
i++;
});
But the above code give me an error which is:
Illegal break statement
How can i break my loop when i==5 ?
Any help is appreciated.