Created
March 25, 2022 06:42
-
-
Save solehudin5699/7a4abbbbae3e90a87935c5fb9bb5e9d3 to your computer and use it in GitHub Desktop.
Revisions
-
solehudin5699 created this gist
Mar 25, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ // 3.___ const convertToStar=(sentences="aa aa")=>{ const sentArr = sentences.split(' '); let newSentences=[] sentArr.forEach((word,idx)=>{ if(word.length>2){ let newWord=''; const lengthWord = word.length word.split('').forEach((char,idx)=>{ if(idx>0&&idx<lengthWord-1){ newWord+="*" }else{ newWord+=char } }) newSentences[idx]=newWord }else{ newSentences[idx]=word } }) return newSentences.join(' ') } console.log(convertToStar('bootcamp fullstack java')) // 4._____ const lengthSentences=(sentences)=>{ const length = sentences.replace(/\s/g, "").length return length } console.log(lengthSentences('bootcamp fullstack java')) // 5.____ const totalWords=(sentences)=>{ const length = sentences.split(' ').length return length } console.log(totalWords('bootcamp fullstack java'))