Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ilyasa Azharil Muhajir : Test Kawah Edukasi Batch III #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions 1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Nama : Ilyasa Azharil Muhajir
// Alamat Email: [email protected]
// Soal Nomor 1

// var data = data1.concat(data2, data3);

// var dataSort = data.sort((a, b) => a > b ? 1 : -1);
// console.log(dataSort);

var data1= [1, 1, 1, 2, 2, 4, 1, 1]
var data2= [2, 1, 2, 2, 2, 8, 1, 1]
var data3= [3, 3, 3, 3, 2, 4, 1, 1]

function cariData(arr) {
let x= 1;
let y= 0;
let item;

for (let i = 0; i < arr.length; i++) {
for (let j = i; j < arr.length; j++) {
if (arr[i] == arr[j]) {
y++;
if (y > x) {
x= y;
item= arr[i];
}
}
}
y= 0;
}
return item;
}

function count(array, value) {
return array.filter((nilai) => (nilai === value)).length
}

console.log("total data paling banyak keluar adalah", cariData(data1), "dengan jumlah", count(data1, 1))
console.log("total data paling banyak keluar adalah", cariData(data2), "dengan jumlah", count(data2, 2))
console.log("total data paling banyak keluar adalah", cariData(data3), "dengan jumlah", count(data3, 3))
24 changes: 24 additions & 0 deletions 2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Nama : Ilyasa Azharil Muhajir
// Alamat Email: [email protected]
// Soal Nomor 2

var input1= "hallo jesika24 selamat datang!";
var input2= "hallo anggun selamat datang!";
var input3= "hallo ** selamat datang!";
var input4= "hallo Mariage889120! selamat datang!";

function cekKalimat(string) {
return /\d/.test(string);
}

console.log(cekKalimat(input1)? "Sistem kami menolak untuk inputan berisi angka " +
input1.match(/\d/g).join(""):"Sistem memeriksa data anda valid dengan ketentuan kami dengan inputan " + input1);

console.log(cekKalimat(input2)? "Sistem kami menolak untuk inputan berisi angka " +
input2.match(/\d/g).join(""):"Sistem memeriksa data anda valid dengan ketentuan kami dengan inputan " + input2);

console.log(cekKalimat(input3)? "Sistem kami menolak untuk inputan berisi angka " +
input3.match(/\d/g).join(""):"Sistem memeriksa data anda valid dengan ketentuan kami dengan inputan " + input3);

console.log(cekKalimat(input4)? "Sistem kami menolak untuk inputan berisi angka " +
input4.match(/\d/g).join(""):"Sistem memeriksa data anda valid dengan ketentuan kami dengan inputan " + input4);
16 changes: 16 additions & 0 deletions 3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

// Nama : Ilyasa Azharil Muhajir
// Alamat Email: [email protected]
// Soal Nomor 3

const bintang= "*";
const spasi= " ";
console.log("Segitiga 1")
for (var baris= 6, bbintang=0; baris > 0; baris--, bbintang++) {
console.log(bintang.repeat(bbintang+1)+spasi.repeat(baris));
}

console.log("\nSegitiga 2")
for (var baris= 5, bbintang=1; baris > 0; baris--, bbintang++) {
console.log(spasi.repeat(baris-1)+bintang.repeat(bbintang));
}
4 changes: 2 additions & 2 deletions test-introduction.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Isilah data pribadi :

Nama :
Alamat Email:
Nama : Ilyasa Azharil Muhajir
Alamat Email: [email protected]
Waktu Mulai :
Waktu Selesai :

Expand Down