Created
December 15, 2015 12:55
-
-
Save chardos/5c5d9b1f79067fec8aad to your computer and use it in GitHub Desktop.
Call array methods on string
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
var original = "There is 1 number."; | |
var updated = Array.prototype.filter.call(original, function(val) { | |
return val.match(/1/); | |
}); | |
// Outputs: ["1"] | |
console.log(updated); | |
// Outputs: "1" | |
console.log(updated.join('')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment