Advertisement
braveheart1989

Daggers and Swords

Oct 15th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let tables = `<table border="1">
  3. <thead>
  4. <tr><th colspan="3">Blades</th></tr>
  5. <tr><th>Length [cm]</th><th>Type</th><th>Application</th></tr>
  6. </thead>
  7. <tbody>\n`;
  8.  
  9.  
  10.     for (let line of input) {
  11.         let width = Number(Math.floor(line));
  12.         if (width <= 10) {
  13.             continue;
  14.         }
  15.         let type = "dagger";
  16.         let application = "blade";
  17.         if (width > 40) {
  18.             type = "sword";
  19.         }
  20.         switch (width % 5) {
  21.             case 0:
  22.                 application = "*rap-poker";
  23.                 break;
  24.             case 1:
  25.                 application = "blade";
  26.                 break;
  27.             case 2:
  28.                 application = "quite a blade";
  29.                 break;
  30.             case 3:
  31.                 application = "pants-scraper";
  32.  
  33.                 break;
  34.             case 4:
  35.                 application = "frog-butcher";
  36.                 break;
  37.         }
  38.  
  39.         tables+=`<tr><td>${width}</td><td>${type}</td><td>${application}</td></tr>
  40. `
  41.     }
  42.     tables+=`</tbody>
  43. </table>`;
  44.  
  45.     console.log(tables);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement