xxxxxxxxxx
const resultDisplayArray = [];
for(let i = 0; i < result.failure.length; i++) {
resultDisplayArray.push(`<li class="text-warning">${result.failure[i]}</li>`);
}
xxxxxxxxxx
function sum(x, y = 5) {
// take sum
// the value of y is 5 if not passed
console.log(x + y);
}
sum(5); // 10
sum(5, 15); // 20
xxxxxxxxxx
function multiply(a, b) {
b = (typeof b !== 'undefined') ? b : 1
return a * b
}
xxxxxxxxxx
function sort(arr = [], direction = 'ascending') {
console.log('I\'m going to sort the array', arr, direction)
}
sort([1, 2, 3])
sort([1, 2, 3], 'descending')