Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

some method in js

// What is someMethod in js?

// Ans: Some method help us to get know about that anything is available in our array or not..

// ========================

// Example
const userCart = [
  { producdId: 1, producdPrice: 355 },
  { producdId: 2, producdPrice: 5355 },
  { producdId: 3, producdPrice: 34 },
  { producdId: 4, producdPrice: 3535 },
];

// ========================

// So here is my array and I want to check prices I want to check that is there is a product that is greater than 10000.

// ========================

console.log(userCart.some((e) => e.producdPrice > 10000));

// So it'll return false as we know..

// ========================

const userCart_2 = [
    { producdId: 1, producdPrice: 355 },
    { producdId: 2, producdPrice: 5355 },
    { producdId: 3, producdPrice: 34 },
    { producdId: 4, producdPrice: 3535 },
{ producdId: 4, producdPrice: 15000 },
  ];

// And it'll return true because in this one I put the product that price is greater than 10000


// ========= The End =========
 
PREVIOUS NEXT
Tagged: #method #js
ADD COMMENT
Topic
Name
6+9 =