Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- var validWeapons = [];
- function Weapon(length, type, name) {
- this.length = length;
- this.type = type;
- this.name = name;
- }
- for (var i in input) {
- var temp = parseFloat(input[i]);
- var tempLength = Math.floor(temp);
- if (tempLength > 10) {
- var tempWeapon = {};
- tempWeapon.length = tempLength;
- if (tempLength > 40) {
- tempWeapon.type = 'sword';
- }
- else {
- tempWeapon.type = 'dagger';
- }
- if ( tempLength % 10 === 1 || tempLength % 10 === 6 ) {
- tempWeapon.name = 'blade';
- }
- else if ( tempLength % 10 === 2 || tempLength % 10 === 7 ) {
- tempWeapon.name = 'quite a blade';
- }
- else if ( tempLength % 10 === 3 || tempLength % 10 === 8 ) {
- tempWeapon.name = 'pants-scraper';
- }
- else if ( tempLength % 10 === 4 || tempLength % 10 === 9 ) {
- tempWeapon.name = 'frog-butcher';
- }
- else if ( tempLength % 10 === 5 || tempLength % 10 === 0 ) {
- tempWeapon.name = '*rap-poker';
- }
- validWeapons.push(tempWeapon);
- }
- }
- console.log('<table border="1">');
- console.log('<thead>');
- console.log('<tr><th colspan="3">Blades</th></tr>');
- console.log('<tr><th>Length [cm]</th><th>Type</th><th>Application</th></tr>');
- console.log('</thead>');
- console.log('<tbody>');
- for (var index in validWeapons) {
- console.log('<tr><td>' + validWeapons[index].length + '</td>' +
- '<td>' + validWeapons[index].type + '</td>' +
- '<td>' + validWeapons[index].name + '</td></tr>');
- }
- console.log('</tbody>');
- console.log('</table>');
- }
Advertisement
Add Comment
Please, Sign In to add comment