Skip to content

Instantly share code, notes, and snippets.

@emtiazahmed27
Last active June 30, 2022 23:43
Show Gist options
  • Save emtiazahmed27/5250f156c32b0d44213cb4084bebf80d to your computer and use it in GitHub Desktop.
Save emtiazahmed27/5250f156c32b0d44213cb4084bebf80d to your computer and use it in GitHub Desktop.
ICBatch05-FinalExam (Problem Solving)
//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