🎯 Day 76 :Convert an Object to an Array of Keys & Values | 100 Days of JavaScript Coding Challenge 🎯

Опубликовано: 07 Январь 2025
на канале: Code with Poonam
52
5

Welcome to Day 76 of the 100 Days of JavaScript Coding Challenge! 🚀
#CodeWithPoonam #100DaysOfCode

📥 Problem Statement:
Write a JavaScript function that takes an object and converts it into an array containing two subarrays:
One for the keys.
One for the values.

📊 Example:
Input: {a: 1, b: 2, c: 3}
Output: [["a", "b", "c"], [1, 2, 3]]

💡 Approach:
✅ Step 1: Use Object.keys() to extract the keys into an array.
✅ Step 2: Use Object.values() to extract the values into an array.
✅ Step 3: Return both arrays inside a nested array.

🌟 Test Scenarios:
✅ {a: 1, b: 2, c: 3} → Output: [["a", "b", "c"], [1, 2, 3]]
✅ {x: 10, y: 20} → Output: [["x", "y"], [10, 20]]
✅ {name: "Code with Poonam", date: "04TH JAN"} → Output: [["name", "date"], ["Code with Poonam", "04TH JAN"]]

📚 Key Takeaways:
✅ Object.keys() returns an array of keys from an object.
✅ Object.values() returns an array of values from an object.
✅ Easy way to convert objects into a nested array structure.

📅 On Day 76, you learned how to convert an object into an array containing two subarrays using Object.keys() and Object.values().
This helps in separating keys and values for easier data handling.
The challenge reinforces working with object methods and array structures in JavaScript.

🔥 Keep pushing forward! Consistency is key!

🎥 Subscribe for more daily coding challenges!
📩 #JavaScript #CodingChallenge #100DaysOfCode #CodeWithPoonam

javascript coding challenge, javascript Coding Challenge Interview Questions 2024, javascript coding interview, javascript array interview questions answers, javascript reduce interview questions, javascript coding questions, javascript coding challenges for beginners, javascript coding examples, javascript interview coding exercises, javascript interview questions and answers for experienced and freshers.#javascriptcoding
javascript coding challenge, javascript Coding Challenge Interview Questions 2024, javascript coding interview, javascript array interview questions answers, javascript strings interview questions answers, javascript object interview questions answers, javascript math interview questions, javascript reduce interview questions, javascript coding interview questions and answers, javascript coding for beginners, javascript coding questions, javascript coding challenges for beginners, javascript coding examples, javascript interview coding exercises, javascript interview questions and answers for experienced and freshers.

Javascript interview questions and answers, javascript interview questions, javascript interview coding exercises, javascript interview questions and answers 2024, javascript interview questions and answers 2023, javascript interview prep, javascript in 12 minutes.