1function greeting (name = 'stranger') {
2 console.log(`Hello, ${name}!`)
3}
4
5greeting('Nick') // Output: Hello, Nick!
6greeting() // Output: Hello, stranger!
1function say(message='Hi') {
2 console.log(message);
3}
4say(); // 'Hi'
5say(undefined); // 'Hi'
6say('Hello'); // 'Hello'
7
8
9function date(d = today()) {
10 console.log(d);
11}
12function today() {
13 return (new Date()).toLocaleDateString("en-US");
14}
15date();
16
17
18function add(x = 1, y = x, z = x + y) {
19 return x + y + z;
20}
21console.log(add()); // 4
22
1function multiply(a, b) {
2 b = (typeof b !== 'undefined') ? b : 1
3 return a * b
4}
1const resultDisplayArray = [];
2for(let i = 0; i < result.failure.length; i++) {
3resultDisplayArray.push(`<li class="text-warning">${result.failure[i]}</li>`);
4}