SHARE
TWEET

Untitled

a guest Jan 24th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let str = "2x PCI-e 4.0 x1, 2x PCI-e 4.0 x16";
  2. let objects = str.split(", ");
  3. let result = {};
  4. objects.forEach(o => {
  5.     let o2 = o.split("x ");
  6.     let amount = Number(o2.shift());
  7.     result[o2.join("")] = amount;
  8. });
  9. console.log(result);
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