DEV Community

Mohan Mogi
Mohan Mogi

Posted on

Object & Array scenario Questions

1.User profile update
const user = {
name: "Vijay",
age:25,
email:"vijay@gmail.com"
};
Update email and add anew property isActive = true.

2.Shopping Cart Total
const cart = [
{name: "shirt", price:500},
{name: "shoes", price:1500},
{name: "cap", price:300}
];
Calculate total price.

3.Find Speccific Object
onst users = [
{ name: "Vijay, age:25"},
{ name: "Arun", age:30},
{ name: "Kumar", age:28}
];
From an array of users,find the user whose name is "arun".

4.count items in Object
const fruits = {
apple:2,
banana: 5,
mango: 3
};
fine the total number of fruits.

Top comments (0)