SHARE
TWEET

12.Multiple Values for a Key

a guest Aug 8th, 2016 268 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function KeyValuePairs(numbers){
  2.     let input = [];
  3.     let duplicateEntry = numbers[numbers.length-1];
  4.  
  5.     for(let i=0 ;i<numbers.length-1;i++){
  6.         let keyValue = numbers[i].split(' ');
  7.         let command = keyValue[0];
  8.         input[command] = keyValue[1];
  9.         if(duplicateEntry==command){
  10.             console.log(input[command]);
  11.         }
  12.     }
  13.     if(duplicateEntry in input){
  14.  
  15.     }
  16.     else{
  17.         console.log("None")
  18.     }
  19. }
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