Advertisement
bebo231312312321

Untitled

Jun 8th, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cars (input){
  2.  const data={}
  3.  
  4. const returnResult = {
  5.     create:(name, inherit, parentName)=>{data[name]= inherit ? Object.create(data[parentName]):{}},
  6.     set: (name, key, value)=>{data[name][key]=value},
  7.  
  8.     print: (name)=>{
  9.          const entry = [];
  10.         for(let key in data[name]) entry.push(`${key}:${data[name][key]}`);
  11.         console.log(entry.join(','));
  12.     },
  13. }
  14. const lines  = input.forEach(line => {const [command, name, key, value] = line.split(" ");
  15. returnResult[command](name,key,value)});
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement