diff --git a/index.js b/index.js index 3fe9b42..cd66e82 100644 --- a/index.js +++ b/index.js @@ -73,12 +73,10 @@ module.exports = { for (let i = 0; i < pathArray.length; i++) { const p = pathArray[i]; - if (!isObject(object[p])) { - object[p] = {}; - } - if (i === pathArray.length - 1) { object[p] = value; + } else if (!isObject(object[p])) { + object[p] = {}; } object = object[p];