///discruct array

let arr = [1,2,3,4,5, "a", "b", "c"]
let letters = [];
function disdestructArray(something) {
    let evenNums = [];
    let oddNums = [];

    for (let word of arr) {

        if (typeof word === "number") {

            if (word%2 === 1) {               
                oddNums.push(word)

            } else {
                evenNums.push(word)
            }

        } else {
            letters.push(word)
        } 
    }

    for (let i = 0; i < evenNums.length; i++) {
        window["even" + (i + 1)] = evenNums[i]
    }

    for (let i = 0; i < oddNums.length; i++) {
        window["odd" + (i + 1)] = oddNums[i]
    }
    return console.log(even1 + "\n" + even2 + "\n" + odd1 + "\n" +
     odd2 + "\n" + odd3 + "\n" + letters)

}
// disdestructArray(arr)



///////destruct string


let arr2 = [1, "abc"];
let number;
function destructString(something) {
    for (let word of something) {
        if (typeof word == "number") {
            number = word;
        } else if (typeof word == "string"){
            for (let i = 0; i < word.length; i++) {
                window["s" + (i + 1)] = word[i]
            }
        } 
    }
    return console.log (number + "\n" + s1 + "\n" + s2 + "\n" + s3)
}
// destructString(arr2)



//////destruct2

let obj = {name: 'Ivan',
           surname: 'Petrov',
           children: [{name: 'Maria'}, {name: 'Nikolay'}]};
let {name, surname, children} = obj
for (let i = 0; i < children.length; i++) {
    let child = children[i]
    window["name" + (i + 1)] = child.name
}
console.log(name1 + "\n" + name2)   


////////destruct3

let arr3 = [1,2,3,4, 5,6,7,10];
let [a, b, ...length] = arr3;
console.log (a + "\n" + b + "\n" + length)
///или именно длина?
console.log(arr3.length)
           