JSFiddle - React, Tailwind, and code Playground

by Evgeniy Kvasyuk

JavaScript

function toPairInvert(arr) {
    if(typeof arr !== 'object' || !arr.length)
        return false;
    
    let result = {};
    for(let key in arr) {
        result[arr[key][0]] = arr[key][1];
    }

    return result;
}

console.log(toPairInvert([['a',2], ['b', 3]]))