SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 150 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function metricConverter(input) {
  2.     let num = Number(input.shift());
  3.     let inputMetric = input.shift();
  4.     let output = input.shift();
  5.     let result = 0.0;
  6.  
  7.     if (inputMetric == "mm" && output == "m") {
  8.         result = num / 1000;
  9.     } else if (inputMetric == "mm" && output == "cm")  {
  10.         result = num / 10;
  11.     } else if (inputMetric == "cm" && output == "mm") {
  12.         result = num * 10;
  13.     } else if (inputMetric == "cm" && output == "m") {
  14.         result = num / 100
  15.     } else if (inputMetric == "m" && output == "mm") {
  16.         result = num*1000;
  17.     } else if (inputMetric == "m" && output == "cm") {
  18.         result = num*100;
  19.     }
  20.     console.log((result).toFixed(3));
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top