Skip to content

Instantly share code, notes, and snippets.

@yonisetiawan
Last active October 6, 2016 08:30
Show Gist options
  • Save yonisetiawan/1f4f1a188e97a211eac761fd31a7f7c3 to your computer and use it in GitHub Desktop.
Save yonisetiawan/1f4f1a188e97a211eac761fd31a7f7c3 to your computer and use it in GitHub Desktop.
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