Created
February 7, 2023 10:56
-
-
Save suryakun/8dfb7e328cf9693745e44ef147c11e3d to your computer and use it in GitHub Desktop.
Simple map reduce
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
const arr : String[] = ["B$u$i$ld", "$t$$h$e", "N$e$x$t", "E$$ra", "$$o$f$", "S$$of$t$wa$r$e", "De$$ve$l$op$me$n$t"]; | |
function buildTheSentence(arr: String[]) : String { | |
const result: String = arr | |
.map((str: String) => (str.match(/[a-zA-Z]/gm) || []).join('')) | |
.reduce((sentence: String, word : String) => sentence + " " + word ) | |
return result; | |
} | |
console.log(buildTheSentence(arr)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment