Last active
March 1, 2018 06:29
-
-
Save cchang62/38b98472c75511c0e4623d03786ff066 to your computer and use it in GitHub Desktop.
JS Bin// source https://jsbin.com/zifakurunu
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 words="Hi there and hello there. there here Welcome and hello there. hello abc"; | |
var wordcnt = words.replace(/[^\w\s]/g, "").split(/\s+/).reduce(function(map, word){ | |
map[word] = (map[word]||0)+1; | |
return map; | |
}, Object.create(null)); | |
console.log(wordcnt) |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var words="Hi there and hello there. there here Welcome and hello there. hello abc"; | |
var wordcnt = words.replace(/[^\w\s]/g, "").split(/\s+/).reduce(function(map, word){ | |
map[word] = (map[word]||0)+1; | |
return map; | |
}, Object.create(null)); | |
console.log(wordcnt) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var words="Hi there and hello there. there here Welcome and hello there. hello abc"; | |
var wordcnt = words.replace(/[^\w\s]/g, "").split(/\s+/).reduce(function(map, word){ | |
map[word] = (map[word]||0)+1; | |
return map; | |
}, Object.create(null)); | |
console.log(wordcnt)</script></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment