Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //02. Letters Combinations
- function lettersCombinations(arg) {
- let char1 = arg.shift()
- let char2 = arg.shift()
- let char3 = arg.shift()
- let code1 = char1.charCodeAt(0)
- let code2 = char2.charCodeAt(0)
- let code3 = char3.charCodeAt(0)
- let output = ''
- let counter = 0
- for (i = code1; i <= code2; i++)
- for (j = code1; j <= code2; j++)
- for (k = code1; k <= code2; k++)
- if (i != code3 && j != code3 && k != code3) {
- counter++
- output += `${String.fromCharCode(i)}${String.fromCharCode(j)}${String.fromCharCode(k)} `
- }
- console.log(`${output}${counter}`)
- }
- lettersCombinations([
- 'a',
- 'c',
- 'b'
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement