Загрузка данных


// _____________             _________________

// _________________________________________________________

// let left = 2; right = 3; это лишнее
// function swapElements (array, left, right) {

//     let leftIndex = 0;
//     let rightIndex = 0;

//     for (let index = 0; index < array; index ++) {
//         const currentElement = array[index];
//         //чтобы не перезаписываеть
//         if (currentElement == right) rightIndex = index;
        
//         if (currentElement == left) leftIndex = index;
                
//     }

//     let temp = array[rightIndex];
//     array[rightIndex] = array[leftIndex];
//     array[leftIndex] = temp;

//     console.log(array);
    
// }

// swapElements(array, undefined, 5)

// function arrayValue (a, ...values) {
//     console.log(a);
    
//     console.log(values);
    
// }
// arrayValue(1, 5, 10)

const words = ['asdfasdf', 'FragmtDirective', 'rgergh',];
function maxLenght (array) {
    let maxLengthIndex = 0, currentWord = array[0];
    for (let index = 0; index < array.length; index++) {
        const element = array[index]
        if (currentWord.length < element.length) {
            maxLengthIndex = index
            currentWord = array[index]
        } 
        
    }
    return maxLengthIndex
}

let resultMax = maxLenght (words)
console.log(words[resultMax]);

function minLenght (array) {
    let minLengthIndex = 0, currentWord = array[0];
    for (let index = 0; index < array.length; index++) {
        const element = array[index]
        if (currentWord.length > element.length) {
            minLengthIndex = index
            currentWord = array[index]
        } 
        
    }
    return minLengthIndex
}

let resultMin = minLenght (words)
console.log(words[resultMin]);
console.log();


function getDifferencia(min, max) {
    let wordLength = min.length, word = " ";
    for (let index = wordLength; index < max.length; index ++) {
        word += max[index]
           
    }
    return word
     
}

console.log (getDifferencia (words[resultMin], words[resultMax]));

function splitString (string) {
    // let pivot = string.length/2, left = "", right =""
    let word = " ", left = " ", right = " ", c = 0
    let split = string.length / 2
    let leftPart = 0, rightPart = 0
    if (split / 2 ==0) {
        leftPart = split - 1
    } else {
        rightPart = (split / 2 = 0.5)
    }
    if (string.length / 2 == 0) {
        for (let i = 0; )
        leftPart = split - 1
    } else {
        rightPart = (split / 2 = 0.5)
    }

    
}