<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.29/browser.js"></script>
<script type="text/babel">
function haveFun(activityName="hiking", time=3) {
console.log(`Today I will go ${activityName} for ${time} hours.`)
}
haveFun("biking", 5);
</script>
<title>Default Parameters</title>
</head>
<body>
</body>
</html>
Strings and Arrays in functions
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.29/browser.js"></script>
<script type="text/babel">
var dog = {
bark(times) {
console.log("bark ".repeat(times));
},
grrr(times) {
console.log("grrr ".repeat(times));
},
snore(times) {
console.log("ZZZ ".repeat(times));
}
};
dog.bark(3);
dog.grrr(4);
dog.snore(5);
var cat = {
meow(times) {
console.log(Array(times+1).join("meow"));
},
purr(times) {
console.log(Array(times+1).join("purr"));
},
snore(times) {
console.log(Array(times+1).join("snore"));
}
};
cat.meow(3);
cat.purr(4);
cat.snore(5);
</script>
<title>Object Literal Enhancement</title>
</head>
<body>
</body>
</html>
Output: