Javascript - nested dictionary from array of strings separated with dots : <p>I have to <strong>translate</strong> an array <strong>to</strong> nested dictionary.</p>

<p>In case i have a string array. each string combined from numbers that seprated by dots,
and each number means a key in the translated dictionary. (except the last number)</p>

<p>e.g.</p>

<p>i have this array:
<code>array = ["5.1.1.1","5.1.1.2","5.1.1.3",..."5.2.1.2","5.2.1.4"..."1.1.1.1"..."1.2.1.3"]</code></p>

<p>and i need output to be this:</p>

<pre><code>var output = {
    '5': {
        '1': {
            '1': [1,2,3],
            '2': [1]
        },
        '2':{
            '1': [2,4],
            '2': [1]
        }
    },
    '1': {
        '1':{
            '1':[1,2,5],
            '2':[1]
        },
        '2':{
            '1':[2,3]
        }
    }
};

</code></pre>

<p>i have an opposite function, which get a nested dictionary and her output is an array.</p>

<p>link: <a href="https://stackoverflow.com/a/59191937/7593555">https://stackoverflow.com/a/59191937/7593555</a></p>

<p>Thanks for helping :).</p>
