Skip to content

Instantly share code, notes, and snippets.

@malcolm-kee
Last active February 16, 2019 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malcolm-kee/d92e8b60ce1369eadc06b7e6f9a88b70 to your computer and use it in GitHub Desktop.
Save malcolm-kee/d92e8b60ce1369eadc06b7e6f9a88b70 to your computer and use it in GitHub Desktop.
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