SHARE
TWEET

A Miner Task

kristina111 Oct 28th, 2016 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function problemSolved(input) {
  2.     var arrDict = {};
  3.     for (var i = 0; i < input.length; i += 2) {
  4.         if (input[i].toLowerCase() == "stop") {
  5.             break;
  6.         }
  7.         else {
  8.             if (arrDict[input[i]] === undefined) {
  9.                 arrDict[input[i]] = 0;
  10.                 arrDict[input[i]] += Number(input[i + 1]);
  11.             }
  12.             else {
  13.                 arrDict[input[i]] += Number(input[i + 1]);
  14.             }
  15.         }
  16.     }
  17.     for (let a in arrDict) {
  18.         console.log((a + " -> " + arrDict[a]).trim());
  19.     }
  20. }
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