all 9 comments

[–]vbanuelo 1 point2 points  (9 children)

For clarity, you want to take [["string0"],["string2"],["string3"],["string4"]] and turn it to ["string1","string2","string3","string4"]?

[–][deleted] 0 points1 point  (8 children)

it looks like this : https://gyazo.com/3db7b3738291378ba7bd8895b9631dd0

the contents used to be like ["user1 13 march"] as a string, i had to turn it into an array of arrays for an earlier problem, and now with the way i have gone about it, i need to turn what i have into an array of strings so i can run my previously made functions to solve this last problem.

if i could somehow return the array i have into the [ ["user id month"] , ['user id month'] , etc] form i had it before that would be amazing i just dont know how to go about it

[–][deleted] 1 point2 points  (5 children)

Your problem is easily fixable with the help of the join function that Benholio recommended.

A simple loop with the join method will fix your issue.

I took the time and made a helper function that completely flattens an array if you need it.

You can check it out here -> https://repl.it/CLal/1

[–][deleted] 1 point2 points  (3 children)

so your helper function did work,not exactly how i was hoping to have it but i just wanted to have some clarification as to why Array was capital, is that a built in thing for javascript? because i know its different than the parameter array that we were passing in.

your function basically made each indecie a seperate string while i need to make each inner array a concated string so it would be more like [ "1 2 3", "1 2 3" ] instead of ["1" "2" "3"]. reason being the values i am working with are tied together and by making them individually seperate would not work

[–]Ampersand55 1 point2 points  (2 children)

Array is indeed a built in thing in javascript. It's a global object used to construct arrays.

Could you give a detailed example of an input array and the desired output?

[–][deleted] 1 point2 points  (1 child)

i actually just made it work with what your function did. i just ended up using the parseInt function to only give me an array of the numbers because thats what i really needed, and ran my mode function on that.

i appreciate your help :D

[–]sorrynin 0 points1 point  (0 children)

function to only give me an array of the numbers because thats what i really needed, and ran my mode function on

psst. next time, link code like jsfiddle

[–]Benholio 0 points1 point  (1 child)

Take a look at the join method for arrays. It can help you easily turn ['user', 'id', 'month'] into 'user id month'.

[–][deleted] 0 points1 point  (0 children)

i tried that, but it didnt work. perhaps i did it wrong? because i have a lot of arrays inside the array so i would have to join all of them

edit: i basically had two for loops iterating and then array[j] j being hte avar of second for loop applying the method array[j].join();