I am working on an array which is like this:
var arr = [
{floor: '1', id: '10165', label: 'Elutuba/Köök'},
{floor: '1', id: '10166', label: 'Tuba 1'},
{floor: '1', id: '10167', label: 'Vannituba'},
{floor: '2', id: '10167', label: 'Vannituba'}
];
Now i want to compare the floor items here. If all the floor value is same, then it should return true and if there are multiple values like '1' & '2' in this array, it should return false.
Here's what i have tried so far
var arr = [
{floor: '1', id: '10165', label: 'Elutuba/Köök'},
{floor: '1', id: '10166', label: 'Tuba 1'},
{floor: '1', id: '10167', label: 'Vannituba'},
{floor: '2', id: '10167', label: 'Vannituba'}
];
for (let i=0; i< arr.length; i++){
for (let j=1; j< arr.length; j++){
if( arr[i].floor !== arr[j].floor){
console.log('found');
}else{
console.log('Not found');
}
}
}
I know this is nowhere close to the solution. But i'm stuck.
Array.prototype.every()