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 8891703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:48:38+00:00 2026-06-14T22:48:38+00:00

I am new to JS and need some basic help: I have a spreadsheet

  • 0

I am new to JS and need some basic help:

I have a spreadsheet which has a square matrix of data.

I can read these data as follows:

  var freqArr     = new Array(new Array());
  var freqSheet   = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("freq");
  var freqRows    = freqSheet.getDataRange();
  var freqNumRows = freqRows.getNumRows();
  freqArr = freqSheet.getRange(2, 2, freqNumRows, freqNumRows).getValues();

I now want to create a an array in memory similar to the one I have read from the sheet

 var tempArr = new Array(new Array());
  for (var i = 0; i <= 3; i++) {
    for (var j = 0; j <= 3; j++) {        
      tempArr [i][j] = freqArr[i][j] ;
    }
  }

As soon as j incs from 0 to 1 and I try to store anything in tempArr [i][j] I get an error “TypeError: Cannot set property “0.0” of undefined to “xxx”

I have tried every combination of creating tempArr that I can think of plus a few more.

  • 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-14T22:48:39+00:00Added an answer on June 14, 2026 at 10:48 pm

    Someone much smarter than myself could probably help you write this better, but the way it looks to me is that you want to create tempArr as the main array, which would have 2 arrays inside of it.

    Inside of each of those arrays are values, so:

    // result: tempArr = [[1,2],[4,5]]
    tempArr = [] // or new Array
    for (var i = 0; i <= 3; i++) {
      tempArr[i] = [];
      for (var j = 0; j <= 3; j++) {        
        tempArr[i].push(freqArr[i][j]);
      }
    }
    

    You create your first main array in tempArr, within your for, each time you loop through, tempArr[i] is created as an array, and inside of the second for, you want to push the value of freqArr to the inner array.

    UPDATE Had a space in tempArr[i] that would’ve caused it to not work for sure. Sorry!

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

Sidebar

Related Questions

I have some basic questions about core data (which I am new to) and
I am pretty new to YUI and need some help. I have a JSON
I am new to Jquery and need some help: I have a div, I
I am relatively new with sql and I need some help with some basic
Im new to python programming and need some help with some basic file I/O
Since I am new to Java, I need some help about some basic things
I have a question...kind of basic but I thought I can take some help
New to XSLT/XML transformations and in need of some basic help if possible. I
I'm brand new to Visual Basic and I need some help with a program
I`m new to JavaScript and I need some help extracting the ID from URL

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.