🎯 Welcome to Day 87 of the 100 Days of JavaScript Coding Challenge!
#CodeWithPoonam #100DaysOfCode
📥 Problem Statement:
Write a JavaScript function to create an object where the keys are numbers from 1 to n and the values are their squares.
📊 Example:
📦 Input: 2
📦 Output: { 1: 1, 2: 4 }
📦 Input: 4
📦 Output: { 1: 1, 2: 4, 3: 9, 4: 16 }
📦 Input: 6
📦 Output: { 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36 }
💡 Approach:
✅ Initialize an Empty Object: Create an empty object result to store key-value pairs.
✅ Loop Through Numbers: Use a for loop from 1 to n.
✅ Assign Values: Assign each key as the number and the value as its square (i * i).
✅ Print the Result: Log the final object to the console.
📚 Key Concepts Used:
✅ Loops: Using the for loop for iteration.
✅ Object Manipulation: Creating and populating objects dynamically.
✅ Mathematical Operations: Calculating squares using basic arithmetic.
📅 On Day 87, you learned how to create an object with keys as numbers and values as their squares in JavaScript using a simple loop.
🔥 Keep coding and stay consistent! 🚀
📩 #JavaScript #CodingChallenge #100DaysOfCode
javascript coding challenge, javascript interview questions, javascript coding interview, javascript array methods, javascript object manipulation, javascript loops, javascript coding for beginners, javascript coding questions, javascript coding examples, javascript practice exercises, javascript interview preparation, javascript programming exercises.
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.