Skip to content
Advertisement

Convert a 2D array into a 1D array

Here is the code I have so far:

JavaScript

I seem to be stuck at this point on how to get [i][s] into a single dimensional array. When I do a print(temp) all the elements of my 2D array print out one a time in order but cannot figure out how to get them into the 1D array. I am a novice 🙁

How to convert a 2D array into a 1D array?

The current 2D array I am working with is a 3×3. I am trying to find the mathematical mode of all the integers in the 2D array if that background is of any importance.

Advertisement

Answer

You’ve almost got it right. Just a tiny change:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement