//for three let str = "hello world"; let arr = str.split(" "); let v1 = arr[0]; let val01 = v1.split("").reverse().join(""); let v2 = arr[1]; let val02 = v2.split("").reverse().join(""); let val03 = []; val03.push(val01, val02); console.log(val03.join(" "));