Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert multidimensional array to string javascript

const arr = [
   'this', [
      'is', 'an', [
         'example', 'of', [
            'multidimentional', 'array'
         ]
      ]
   ]
];
const arrayToString = (arr) => {
   let str = '';
   for(let i = 0; i < arr.length; i++){
      if(Array.isArray(arr[i])){
         str += `${arrayToString(arr[i])} `;
      }else{
         str += `${arr[i]} `;
      };
   };
   return str;
};
console.log(arrayToString(arr));

//output : this is an example of multidimentional array
Comment

PREVIOUS NEXT
Code Example
Javascript :: js array split by comma 
Javascript :: used to retrieve dat from firebase realtime datastore 
Javascript :: define maxmum size of schema field in nodejs 
Javascript :: how to manage logging using winston for production and development in node js "github" 
Javascript :: change build directory react 
Javascript :: js create md5 hash 
Javascript :: add an object to an array mongosse 
Javascript :: js falsy values 
Javascript :: react router history not defined 
Javascript :: getJSON how to set async to false 
Javascript :: next js environment variables 
Javascript :: jquery function done 
Javascript :: jquery date format 
Javascript :: break statement in javascript 
Javascript :: javascript input file callback 
Javascript :: react background gradient 
Javascript :: switch react router 
Javascript :: json.stringify 
Javascript :: react navigation hide header 
Javascript :: dummy data json 
Javascript :: mongoose get id after save 
Javascript :: add getter to object javascript 
Javascript :: cra proxy 
Javascript :: base64 to pdf in replace nodejs 
Javascript :: nginx get request method 
Javascript :: passport js local strategy response handling 
Javascript :: background colour in react 
Javascript :: javascript beginning of today and yesterday 
Javascript :: javascript list class properties 
Javascript :: what does sanitize do javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =