Created
June 5, 2021 08:26
-
-
Save ezcomenezgo/02b19ef41a8a76a100be2308ddbb3d47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let firstInput = document.querySelector('#firstInput') | |
let secondInput = document.querySelector('#secondInput') | |
const btn = document.querySelector('button'); | |
let arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] | |
let length = arr.length | |
btn.addEventListener('click', function () { | |
// console.log(firstInput.value[0]); | |
// console.log(firstInput.value[1]); | |
for (let i = 0; i < length; i++) { | |
if (firstInput.value[0] === arr[i]) { | |
// console.log('Input1 vs arr1', firstInput.value[0], arr[i]) | |
} | |
for (let j = 0; j < length; j++) { | |
if (firstInput.value[1] === arr[j]) { | |
// console.log('Input2 vs arr2', firstInput.value[1], arr[j]) | |
for (let k = j; k < length; k++) { | |
console.log(`third loop: ${firstInput.value[0]}${arr[k]}`) | |
} | |
} | |
// console.log(`i+j:${arr[i]}${arr[j]}`) | |
} | |
break | |
} | |
// console.log(arr.indexOf(secondInput.value[0])) | |
// console.log(arr.indexOf(firstInput.value[0])) | |
for (let i = arr.indexOf(firstInput.value[0]) + 1; i < arr.indexOf(secondInput.value[0]); i++) { | |
// console.log('second for:', i, arr[i]) | |
for (let j = 0; j < arr.length; j++) { | |
console.log(`i+j:${arr[i]}${arr[j]}`) | |
} | |
} | |
for (let i = 0; i < length; i++) { | |
if (secondInput.value[0] === arr[i]) { | |
console.log('Input3 vs arr1', secondInput.value[0], arr[i]) | |
} | |
for (let j = 0; j < length; j++) { | |
if (secondInput.value[1] === arr[j]) { | |
// console.log('Input4 vs arr2', secondInput.value[1], arr[j]) | |
// console.log(typeof arr.indexOf(secondInput.value[1])) | |
for (let k = 0; k <= arr.indexOf(secondInput.value[1]); k++) { | |
console.log(`third2 loop: ${secondInput.value[0]}${arr[k]}`) | |
} | |
} | |
// console.log(`i+j:${arr[i]}${arr[j]}`) | |
} | |
break | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment