Reverse the words in string
In javascript, strings are immutable 


  For character access using bracket notation, attempting to delete or assign a value to these properties will not succeed. The properties involved are neither writable nor configurable. (See Object.defineProperty() for more information.)


So this was either a trick question or the creator was not aware.

The only "mutable string representation" of a javascript string would be an array.

So if the question accepts using an array as the representation of the string, you could do something like this:



function reverse(str){
  const mutable = str.split("");
  
  for(let i = 0; i &lt; mutable.length/2; i++){
    const j = mutable.length-1-i;
    const c = mutable[i];
    mutable[i] = mutable[j];
    mutable[j] = c;
  }
  
  return mutable.join("");
}

const res = reverse("hello world");

console.log(res);