Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Multi Cursor Exercise
<!DOCTYPE html5>
<html>
<body>
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Malcolm</td>
<td>28</td>
</tr>
<tr>
<td>Baby</td>
<td>1</td>
</tr>
<tr>
<td>Dad</td>
<td>50</td>
</tr>
<tr>
<td>Mum</td>
<td>50</td>
</tr>
<tr>
<td>Brother</td>
<td>30</td>
</tr>
<tr>
<td>Sinchan</td>
<td>5</td>
</tr>
</tbody>
</table>
</body>
</html>
function add() {
// different add
}
(function app($) {
function add() {
var total = 0;
for (let index = 0; index < arguments.length; index++) {
var arg = arguments[index];
if (arg) {
total += arg;
}
}
return total;
}
$('.calculate-btn').on('click', function() {
var $inputs = $('.input-number');
var total = add.apply(
null,
$.map($inputs, function($input) {
return $input.val();
})
);
$('.total-display').text(total);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.