JSFiddle - React, Tailwind, and code Playground

by wales

JavaScript

function solution(str){
  let result = "";
  let i;
  console.log(str.length)
  for( i = str.length; i > 0; i--){
    result = result + str.substring(i, i-1)
    console.log(result)
  }
  return result;
}

solution("world")