Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js reverse a strings in array

function spinWords(string){
  //split("")the 5 letter word up ["h","e","l","l","o"]
  let strArr=string.slice(0).split(" ");
  console.log(strArr);
  for(let i=0;i<=strArr.length-1;i++){
    if(!strArr[i].length>=5)return strArr.join(" ");
   if(strArr[i].length>=5) strArr[i]=strArr[i].split("").reverse().join("");
}

return strArr.join(" ");
}
Source by ideone.com #
 
PREVIOUS NEXT
Tagged: #js #reverse #strings #array
ADD COMMENT
Topic
Name
7+1 =