function calc(){
var select = document.querySelectorAll('.calc>select');
let values = []
let result = 1
for (i = 0; i < select.length; i++){
values.push(+select[i].value)
result *= +select[i].value
select[i].setAttribute('data-index', i)
select[i].onchange = function(e){
const index = e.target.getAttribute('data-index')
result = result / +values[index] * +e.target.value
values[index] = +e.target.value
document.getElementById('result').innerHTML = result+'р.';
}
}
}
const path = 'dir1/dir2/dir3/dir4/'
let arr = []
path.slice(0,-1).split('/').forEach((item,l,items) => {
let obj = {key: item, path: ''}
for(let i = 0; i <= l; i++) {
obj.path += items[i] + '/'
}
arr.push(obj)
})
console.log(arr)