Basic Algorithm Scripting - Reverse a String

Hi there i noticed thorugh this challange that the string is referenced like an array
heres the code that reverses a string

function reverseString(str) {
  let x=''
  for(let i=str.length-1; i>=0;i--){
    x= x.concat(str[i])
  }
  return x;
}

reverseString("hello");

does this mean that if i create an array with characters that i can treat it as a string?
could i do this challange via creating an array let x= and unshifting str[i] into x at every position of str[i] from beginning to end?
i tried to do it but it failed ?
i imagine this is because there is a comma between every array item?
if so is there a way to remove said comma to return transform from array into a string that has no commas between?

There is no comma.
An array is a series of areas in memory that are referenced by the array’s variable name.

The comma is just how the console prints out the values so human beings can read them.

Bracket notation is used to access the values in the array.

Push and pop and shift and unshift will either add to the end, remove from the end, remove from the start or add to the start depending on which one you call.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.