JSFiddle - React, Tailwind, and code Playground

by Mariya_Korotkova

HTML

<h1>
Hello!
</h1>

JavaScript

function order(words){
  // ...
  let arr = words.split(' ');
  let newArr = [];
  let index;
  console.log('newArr', newArr);
  console.log('arr', arr);
  
  arr.forEach((item, i , array) => {
    let word = item.split('');
    	word.forEach((item) => {
    		if (item == parseInt(item)) {
    		index = item;
    		console.log(index);
    	}
    
    
    })
    newArr[index - 1] = array[i];
      console.log('ARR', arr);

    console.log('NEW', newArr);
  })
 words = newArr.join(' ');
 console.log(words);
  return words;
}

order("is2 Thi1s T4est 3a");