GSG-G7 / AMAI

week1 project
https://ca-g7.github.io/AMAI/
0 stars 1 forks source link

DRY ! #63

Open aminalakhsham opened 5 years ago

aminalakhsham commented 5 years ago

https://github.com/ca-g7/AMAI/blob/964a341fb1c8deb85b647d120ea3457c42f22e62/JS/index.js#L1-L9 try to make this function to don't repeat code

function getElements(nodesName, selectors) {
  const elements = {}
  if (nodesName.length === selectors.length) return 'Error';
    selectors.map((selector, index) =>
      elements[nodesName[index]] = document.querySelector(selector);)
return elements;
}

const {a, b, c} = getElements(['a','b','c'], ['.a','.b','.c']);