JavaScript Bug: Auto-Corrected Mistake in Length Property

What is the correct output ? function addsum() {  let sum = 0;   for (let i = 0; i < arr.lenght; i++) {    sum = sum + arr[i];   }   return sum; } const arr = [1, 2, 3]; console.log(addsum(arr)); Everyone thinks its very simple and output is 6 ✅ Most people glance at this and immediately say its 6. We read code the same way we read a newspaper. Our brain auto-corrects mistakes without us realizing it. Your eyes didn’t catch it. and move on. Your mind assumed it was correct. You saw "length". But the code actually has "lenght". - Don’t trust your eyes. - Don’t trust assumptions. - Trust execution and attention to detail. - On the first read, your brain auto-corrects the mistake; on the second read,your eyes finally notice the error. #JavaScript #ReactJS #FrontendDevelopment #WebDevelopment #SoftwareEngineering #Debugging #CleanCode #DeveloperMindset #CodingMistakes #Programming #BugHunting #InterviewQuestions #JavaScriptInterview #TechCareers #LearnToCode #CodeQuality #ReactJS #JSX #WebSecurity #XSS #FrontendTips #JavaScript #SafeCoding #ReactInterview

To view or add a comment, sign in

Explore content categories