π¦
Array to Object
Array to Objectμ¬μ κ°μ²΄ +10pts
Problem
Write a function that converts an array of [key, value] pairs to an object.
Examples
Input:
arrayToObj([["a", 1], ["b", 2]])Output:
{a: 1, b: 2}Explanation
μ΄ λ¬Έμ λ **Object.fromEntries()**λ₯Ό μ¬μ©νμ¬ [ν€, κ°] μμ λ°°μ΄μ κ°μ²΄λ‘ λ³ννλ λ°©λ²μ νμ΅ν©λλ€. ## ν΅μ¬ κ°λ : λ°°μ΄μ κ°μ²΄λ‘ λ³ν Object.fromEntries()λ Object.entries()μ μμ°μ°μ λλ€. ### κΈ°λ³Έ μ¬μ©λ² ```javascript Object.fromEntries(iterable) ``` - ES2019μμ λμ - [ν€, κ°] μμ μ΄ν°λ¬λΈμ κ°μ²΄λ‘ λ³ν ### νμ© μμ ```javascript Object.fromEntries([["a", 1], ["b",...
View detailed explanation βKey Concepts
Object.fromEntries λ°°μ΄-κ°μ²΄ λ³ν ES2019 Map λ³ν
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.