JSFiddle - React, Tailwind, and code Playground

JavaScript

const fromDBtoJS = (obj) => {
    const result = {};

    Object.keys(obj).forEach((key) => {
        const newKey = key.replace(/_[a-z]/g, function (x) { return x[1].toUpperCase(); });
        result[newKey] = obj[key];
    });

    return result;
};

const test = {
    first_name: 'Spongebob',
    last_name:  'Squarepants',
};

const final = fromDBtoJS(test);

console.log(final);