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];

  const splitNewString = newString.split(' ')

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

my output:


output I want:

script java hello

Read more here:

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: