Advertisement
ralka

12. multipleValueKey

Jun 17th, 2016
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.51 KB | None
  1. "use strict"
  2.  
  3. function multipleKeyValue(args) {
  4.     let arr = [];
  5.     let someKey = args[args.length - 1];
  6.     for (let i = 0; i < args.length - 1; i++){
  7.         let pair = args[i].split(' ');
  8.         let key = pair[0];
  9.         let value = pair[1];
  10.         arr[key] = value;
  11.         if (someKey == key){
  12.             console.log(arr[key]);
  13.         }
  14.     }
  15.  
  16.     if (someKey in arr){
  17.  
  18.     }
  19.     else console.log("None");
  20.  
  21.  
  22. }
  23.  
  24. multipleKeyValue(['key value',
  25.     'key eulav',
  26.     'test value',
  27.     'my'])
Advertisement
RAW Paste Data Copied
Advertisement