Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:57:48+00:00 2026-06-10T11:57:48+00:00

Working on a codecademy tutorial where I’m supposed to print out the cells of

  • 0

Working on a codecademy tutorial where I’m supposed to print out the “cells” of the table (the array within the array) like this

Cell Cell Cell

with two spaces between each cell. I’m assuming the result (for the first “row”) will look like

Person  Age  City

There should be no space at the end of the “row”.

I wrote the disastrous for loop below trying to follow the instructions from codecademy (copied below) but can’t get it to work. Can anyone give me a hand…

var table = [
    ["Person",  "Age",  "City"],
    ["Sue",     22,     "San Francisco"],
    ["Joe",     45,     "Halifax"]
];

for (var r in table) {       ////// I wrote this for statement
    var c;
    var cells = table[r]; 
    var rowText = ""; 
    for(c = 0; c < cells; c++){
        rowText += table[r][c];
        if(c < cells - 1){         //only adds the space if not at end of line
            rowText += "  "; 
        }
    }

    console.log(rowText); 

}

Instructions from Codecademy.com

We want to add another for loop and some formatting code so that we
can print out each of the three rows in the following format:

Cell Cell Cell

There should be two spaces between each of the cell values, but not at
the end of a line. Each row should be on a separate line.

In-depth instructions are in the exercise hint.

Remove the console.log statement in the body of the for loop. In the
body of the for loop, define a variable c. Also define a variable
named cells and set it equal to the length of the current row (which
can be found with table[r]). Define an empty string variable named
rowText. Make sure to set rowText is set to “”. Define another for
loop immediately after the variables from step 2.

In the first loop parameter, set c equal to 0. In the second loop
parameter, make sure that the loop stops after c is one less than
cells. In the third loop parameter, increment c. In the body of the
loop from step 3, append the current cell (which can be found with
table[r][c]) to rowText. Use an if statement to also append two space
characters (this is ” “) to rowText if c is not the position of the
last cell in the row (this is true when c is less than cells – 1)
After the entire loop body from step 3, but inside of the loop body
from the last exercise, use console.log to print rowText.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:57:49+00:00Added an answer on June 10, 2026 at 11:57 am

    use cells.length not cells I would think

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a codecademy.com tutorial where we're building a cash register. I'm supposed
I'm working on codecademy.com JavaScript tutorial. This lesson on objects. I have a feeling
Working on a project, I have this issue where my array slicetable returns undefined
Working on this EF tutorial , I've difficult to understand the meaning of the
I'm working on a JavaScript tutorial at codecademy.com It starts by giving you the
I'm working on a codecademy.com lesson where I'm supposed to check if a number
Working with H2 I get this error when I try to write a row
Working on a project using Entity Framework (4.3.1.0). I'm trying to figure out how
Working on an old Kohana 2 project and I want to link two models.
Working through the five minute Xtext tutorial (http://www.eclipse.org/Xtext/documentation/2_1_0/010-xtext-in-5-minutes.php) I get to Generating The Language

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.