JSFiddle - React, Tailwind, and code Playground

by ChangJoo Park

JavaScript

function solution(clothes) {
  const hash = {}
  
  for (let i = 0; i< clothes; i++) {
      const current = clothes[i]
      console.log('current => ', current)
      if (!hash[current[1]]) {
          hash[current[1]] = []
      }
      hash[current[1]].push(current[0])
  }
  console.log(hash)
  var answer = 0;
  return answer;
}


solution([["yellow_hat", "headgear"], ["blue_sunglasses", "eyewear"], ["green_turban", "headgear"]])