The numbers just don't add up - How do I know what a console should display if it substitutes everything with "undefined"?

Hello to anyone who may be reading this,

Lately I’ve been having some trouble with printing code including loops to the console. Because when I hit return, the console replies to the code with “undefined”. This goes for mozilla scratchpad, firefox and chrome. However, when I just do a simple code like “console.log(‘Something’);” the console prints the code correctly. How am I meant to practise when the console just says “undefined”?

Here’s the the code I’m trying to log:

var nuclearCountries = [
‘North Korea (DPRK)’,

var northAmericanCentralCountry = ‘United States of America’;
var someAsian = ‘India’;

for (var i = 0; i <= nuclearCountries.length; i++) {


Is there some problem with my code?

Help appreciated,

That console log should be inside your for loop block. That’s a scope problem.
Don’t define your variables after their implementation either.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.