Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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
 
PREVIOUS NEXT
Tagged: #convert #multidimensional #array #string #javascript
ADD COMMENT
Topic
Name
8+2 =