Last active
June 30, 2022 23:43
-
-
Save emtiazahmed27/5250f156c32b0d44213cb4084bebf80d to your computer and use it in GitHub Desktop.
ICBatch05-FinalExam (Problem Solving)
This file contains 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 characters
//Write a function that counts words in a String | |
function wordCount(str){ | |
let arr=str.split(" "); | |
return arr.filter((word)=>word!="").length; | |
} | |
console.log(wordCount("javaScript exam e bash khabo please wish me luck ")); | |
console.log(wordCount("javaScript exam e bash khabo please wish me luck")); | |
//output: 9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment