const phones = [
{ name: 'samsung s5', price: 45000, camera: 10, storage: 32 },
{ name: 'walton', price: 15000, camera: 8, storage: 8 },
{ name: 'shaomi m3', price: 12000, camera: 10, storage: 16 },
{ name: 'oppo a2', price: 17000, camera: 10, storage: 32 },
{ name: 'Nokia n95', price: 8000, camera: 10, storage: 4 },
{ name: 'htc h81', price: 25000, camera: 10, storage: 16 }
]
let cheapest = phones[0];
for (let phone of phones) {
if (phone.price < cheapest.price) {
cheapest = phone;
}
}
console.log(cheapest);
//{ name: 'Nokia n95', price: 8000, camera: 10, storage: 4 }