JavaScript Interview Question: Calculate Total Price of Nested Array

🔥 JavaScript Real Interview Questions Series  Let’s level up your JS game! Here’s a commonly asked interview question based on arrays, objects, and recursion 👇 const outfit = [  { name: "Cool Hat", price: 20 },  { name: "Cool Tee Shirt", price: 25 },  {  category: "Accessories",  inventory: [   { name: "Cool Sunglasses", price: 150 },   { name: "Cool Watch", price: 400 },   {   category: "Jewelry",   inventory: [    { name: "Cool Earrings", price: 25 },    { name: "Cool bracelet", price: 40 },    { name: "Cool Necklace", price: 80 },   ],   },   { name: "shorts", price: 42 },   { name: "flip flops", price: 22 },  ],  }, ]; 💡 Interview Question:  👉 Write a function to calculate the total price of all items, including nested inventory. 🎯 What Interviewers Are Testing: -Understanding of nested objects -Knowledge of arrays & array methods -Use of recursion -Clean and optimized logic -Edge case handling 💬 Pro Tip:  Most JavaScript interviews heavily focus on Arrays and Strings.  If your fundamentals are strong, 50% of the battle is already won. Do not forget to follow : Yogesh Sharrma Comment your solution below 👇  Follow for more JavaScript Interview Series 🔥 #JavaScript #FrontendDeveloper #WebDevelopment #CodingInterview 

To view or add a comment, sign in

Explore content categories