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

I Wayan Ari Pramana Putra : Test Kawah Edukasi bath III #16

Open
wants to merge 2 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
8 changes: 4 additions & 4 deletions test-introduction.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Isilah data pribadi :

Nama :
Alamat Email:
Waktu Mulai :
Waktu Selesai :
Nama : I Wayan Ari Pramana Putra
Alamat Email: [email protected]
Waktu Mulai : 11.00 WITA
Waktu Selesai : 14.10 WITA

CARA PENGERJAAN!!!

Expand Down
38 changes: 38 additions & 0 deletions test_soal1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Disini var saya ubah dengan let karena ketentuan ES6 dengan best practice

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

let hitung = {};
let bandingkan = 0;
let seringMuncul = undefined;
let jumlahData = undefined;

const cariTerbanyak = (arr) => {
for (let i = 0; i < arr.length; i++) {
let word = arr[i];

if (hitung[word] === undefined) {
hitung[word] = 1;
} else {
hitung[word] = hitung[word] + 1;
}

if (hitung[word] > bandingkan) {
bandingkan = hitung[word];
seringMuncul = arr[i];
}

let length = arr.length - 2;

jumlahData = length - seringMuncul;
}
console.log(
`total data paling banyak keluar adalah ${seringMuncul} dengan jumlah ${jumlahData}`
);
};

cariTerbanyak(data3);
cariTerbanyak(data2);
cariTerbanyak(data1);
27 changes: 27 additions & 0 deletions test_soal2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Disini var saya ubah dengan let karena ketentuan ES6 dengan best practice

let input1 = 'hallo jesika24 selamat datang!';
let input2 = 'hallo anggun selamat datang!';
let input3 = 'hallo ** selamat datang!';
let input4 = 'hallo Mariage889120! selamat datang!';

const checkInputUser = (i) => {
let regexp = /\d/g;
let inString = i.match(regexp);
if (inString) {
let inValidasi = i.match(regexp).join('');
}

if (inValidasi != null) {
console.log(`Sistem kami menolak untuk inputan berisi angka ${inValidasi}`);
} else {
console.log(
'Sistem memeriksa data anda valid dengan ketentuan kami dengan inputan hallo justin selamat datang!'
);
}
};

checkInputUser(input1);
checkInputUser(input2);
checkInputUser(input3);
checkInputUser(input4);
30 changes: 30 additions & 0 deletions test_soal3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const TriangleStar = (jmlh) => {
let star = '';

for (let i = 0; i < jmlh; i++) {
for (let j = 0; j <= i; j++) {
star += '*';
}
star += '\n';
}
console.log(star);
};

TriangleStar(6);

function reverseTriangleStar(jmlh) {
let bintangTerbalik = '';

for (let i = jmlh; i > 0; i--) {
for (let j = 0; j <= jmlh; j++) {
if (j >= i) {
bintangTerbalik += '*';
} else {
bintangTerbalik += ' ';
}
}
bintangTerbalik += '\n';
}
console.log(bintangTerbalik);
}
reverseTriangleStar(6);