JacobHsu
2/9/2017 - 5:36 AM

ES6 toUpperCase JS Bin// source https://jsbin.com/tesoqay

ES6 toUpperCase JS Bin// source https://jsbin.com/tesoqay

"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);
}());

*/
<!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>