Last active
August 26, 2015 03:49
-
-
Save KimiEatsCode/86dca882e798d5003c74 to your computer and use it in GitHub Desktop.
Create Object from a JS Function
This file contains hidden or 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
A [Pen](http://codepen.io/sarahkmcaleer/pen/LVwaPG) by [Sarah McAleer](http://codepen.io/sarahkmcaleer) on [CodePen](http://codepen.io/). | |
[License](http://codepen.io/sarahkmcaleer/pen/LVwaPG/license). |
This file contains hidden or 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
function superCounter (x) { | |
var person = { | |
words: x.split(" ").length, | |
chars: x.split("").length, | |
avgLength: (x.split("").length/x.split(" ").length).toFixed(2), | |
spaces: x.split(/\s/g).length-1 | |
} | |
var jsonText = JSON.stringify(person); | |
document.write(jsonText); | |
}; | |
superCounter("A constructor is any function which is used As a constructor"); | |
This file contains hidden or 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
body { | |
color:#000; | |
text-align:center; | |
font-size:1.5em; | |
font-family: Chonburi; | |
margin-top:50px; | |
color:#7A2A3C; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment