Advertisement
ErolKZ

Untitled

Jun 13th, 2021
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. function solve(input) {
  2.  
  3.  
  4. let chislo = Number(input[0]);
  5. let input1 = input[1];
  6. let output = input[2];
  7. let final = 0;
  8.  
  9.  
  10. if (input1 === 'mm' && output === 'm') {
  11.  
  12. final = chislo / 1000;
  13. console.log(final.toFixed(3));
  14.  
  15. } else if (input1 === 'm' && output === 'cm') {
  16.  
  17. final = chislo * 100;
  18. console.log(final.toFixed(3));
  19.  
  20. } else if ( input1 === 'cm' && output === 'mm') {
  21.  
  22. final = chislo * 10;
  23. console.log(final.toFixed(3));
  24.  
  25. } else if (input1 === 'mm' && output === 'cm') {
  26.  
  27. final = chislo / 10;
  28. console.log(final.toFixed(3));
  29.  
  30.  
  31. } else if (input1 === 'cm' && output === 'm') {
  32.  
  33. final = chislo / 100;
  34. console.log(final.toFixed(3));
  35.  
  36.  
  37. } else if (input1 === 'm' && output === 'mm') {
  38.  
  39. final = chislo * 1000;
  40. console.log(final.toFixed(3));
  41.  
  42.  
  43. }
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement