Skip to content

Latest commit

 

History

History
27 lines (25 loc) · 822 Bytes

Password Creation.md

File metadata and controls

27 lines (25 loc) · 822 Bytes

Screen Shot 2022-03-08 at 18 56 51

Screen Shot 2022-03-08 at 18 56 41

function newPassword(a, b) {
    // Write your code here
    let res = '';
    let count = 0;
    let minLength = Math.min(a.length, b.length);
    for(let i = 0; i < minLength; i++) {
        res += a[i] + b[i];
        count += 1;
    }
    if(a.length > b.length) {
        for(let i = count; i < a.length; i++) {
            res += a[i];
        }
    }
    else {
        for(let i = count; i < b.length; i++) {
            res += b[i];
        }
    }
    return res;
}