Last active
February 16, 2019 05:48
-
-
Save malcolm-kee/d92e8b60ce1369eadc06b7e6f9a88b70 to your computer and use it in GitHub Desktop.
Multi Cursor Exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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