every()

input type callback function and retrun true / false check if every value are matched than return true otherwise false. return only true or false. isme har ko check karega agra saare match krenge to true dega nahin match kare to false dega.

// const numbers = [2,4,6,9,10];
// const ans = numbers.every((number)=>number%2===0);

// console.log(ans);

const userCart = [
    {productId: 1, productName: "mobile", price: 12000},
    {productId: 2, productName: "laptop", price: 22000},
    {productId: 3, productName: "tv", price: 35000},
]

const ans = userCart.every((cartItem)=>cartItem.price < 30000);
console.log(ans); ---------true or false 

Posted

in

by

Tags: