Skip to content

Instantly share code, notes, and snippets.

@JacobHsu
Forked from anonymous/index.html
Last active February 9, 2017 05:37
Show Gist options
  • Save JacobHsu/52104efb461e9103bba1c0929f0c46f1 to your computer and use it in GitHub Desktop.
Save JacobHsu/52104efb461e9103bba1c0929f0c46f1 to your computer and use it in GitHub Desktop.
ES6 toUpperCase JS Bin// source https://jsbin.com/tesoqay
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<button id="main_button">click me</buttton>
<script id="jsbin-javascript">
"use strict";
{
(function () {
"use strict";
var capify = function capify(str) {
return [str.charAt(0).toUpperCase(), str.substring(1)].join("");
};
var processWords = function processWords(fn, str) {
return str.split(" ").map(fn).join(" ");
};
var getValue = function getValue() {
var something = prompt("Give me something to capitalize");
alert(processWords(capify, something));
};
document.getElementById("main_button").addEventListener("click", getValue);
})();
}
/*
(function() {
"use strict";
var capify = function(str) {
return [str.charAt(0).toUpperCase(), str.substring(1)].join("");
};
var processWords = function(fn, str) {
return str.split(" ").map(fn).join(" ");
};
var getValue = function(e) {
var something = prompt("Give me something to capitalize");
alert(processWords(capify, something));
};
document.getElementById("main_button").addEventListener("click", getValue);
}());
*/
</script>
<script id="jsbin-source-javascript" type="text/javascript">{
"use strict";
const capify = str => [str.charAt(0).toUpperCase(), str.substring(1)].join("");
const processWords = (fn, str) => str.split(" ").map(fn).join(" ");
const getValue = () => {
let something = prompt("Give me something to capitalize");
alert(processWords(capify, something));
}
document.getElementById("main_button").addEventListener("click", getValue);
}
/*
(function() {
"use strict";
var capify = function(str) {
return [str.charAt(0).toUpperCase(), str.substring(1)].join("");
};
var processWords = function(fn, str) {
return str.split(" ").map(fn).join(" ");
};
var getValue = function(e) {
var something = prompt("Give me something to capitalize");
alert(processWords(capify, something));
};
document.getElementById("main_button").addEventListener("click", getValue);
}());
*/</script></body>
</html>
"use strict";
{
(function () {
"use strict";
var capify = function capify(str) {
return [str.charAt(0).toUpperCase(), str.substring(1)].join("");
};
var processWords = function processWords(fn, str) {
return str.split(" ").map(fn).join(" ");
};
var getValue = function getValue() {
var something = prompt("Give me something to capitalize");
alert(processWords(capify, something));
};
document.getElementById("main_button").addEventListener("click", getValue);
})();
}
/*
(function() {
"use strict";
var capify = function(str) {
return [str.charAt(0).toUpperCase(), str.substring(1)].join("");
};
var processWords = function(fn, str) {
return str.split(" ").map(fn).join(" ");
};
var getValue = function(e) {
var something = prompt("Give me something to capitalize");
alert(processWords(capify, something));
};
document.getElementById("main_button").addEventListener("click", getValue);
}());
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment