Last active
October 6, 2016 08:30
-
-
Save yonisetiawan/1f4f1a188e97a211eac761fd31a7f7c3 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
const readline = require('readline'); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
var peserta = []; | |
function pertanyaan(x){ | |
if(x > 0){ | |
rl.question('Input Nama Kandidat ', (answer) => { | |
peserta.push(answer) | |
return pertanyaan(x-1) | |
}); | |
}else{ | |
var hasil = []; | |
for (var j = 0; j < peserta.length; j++) { | |
for (var i = 1; i < peserta.length; i++) { | |
if(peserta[j]!==peserta[i]){ | |
hasil.push([peserta[j]+", "+peserta[i]]) | |
} | |
} | |
} | |
console.log(hasil) | |
rl.close(); | |
} | |
} | |
pertanyaan(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment