Default Parameters in Functions using JavaScript #coding #shorts

preview_player
Показать описание
What will be the output of the following JavaScript code snippet?”

function add(a, b = 2) {
return a + b;
}
❓Options:
a) 2
b) 5 ✅
c) 3
d) undefined

🚀 JavaScript Quiz Time!
Test your JS fundamentals with this quick output-based question. Do you know how default parameters work in functions? 🤔
In the following snippet, the second argument has a default value. What will be logged to the console? 💻

👇 Drop your answer in the comments!
💬 Let’s see who gets it right without running the code!
✅ Correct answer is: b) 5

💡 Explanation:
add(3) passes only one argument, so b defaults to 2. Hence, 3 + 2 = 5.

💥 Like ❤️
🔁 Share with your dev friends
📲 Follow @codebypc for daily coding content
💬 Comment your thoughts, and let me know what topic you want next!

#JavaScript #CodingReels #WebDevelopment #FrontendDeveloper #CodeQuiz
#LearnToCode #JSOutput #CodeChallenge #TechReels #codebypc #youtubeshorts #viralshorts #shots
Рекомендации по теме
welcome to shbcf.ru