Combines two arrays into one sentence

I'm new in javascript and I don't know how to merge some array. I want to reverse word manually but I mess up. It's my code:

function reverseString(kata) {
  let currentString = kata;
  let newString = '';
  let cetakKata = '';
  for (let i = kata.length - 1; i >= 0; i--) {
    newString = newString + currentString[i];
  }
  console.log(newString);

  const splitNewString = newString.split(' ')
  console.log(splitNewString);

  for (let i = 0; i < splitNewString.length; i++) {
    const cetak = splitNewString[i].split('').reverse().join('')
    cetakKata = cetakKata + cetak
  }
  console.log(cetakKata);
}
reverseString('hello java script');

my output:

scriptjavahello

output I want:

script java hello


Read more here: https://stackoverflow.com/questions/64942340/combines-two-arrays-into-one-sentence

Content Attribution

This content was originally published by Tommy at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: