Advertisement
soden

Untitled

Feb 24th, 2024
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.66 KB | Source Code | 0 0
  1. // Deklarasi variabel nomorHari
  2. var nomorHari = 3;
  3. var namaHari;
  4.  
  5. // Percabangan switch untuk menentukan nama hari berdasarkan nomor hari
  6. switch (nomorHari) {
  7.     case 1:
  8.         namaHari = 'Minggu';
  9.         break;
  10.     case 2:
  11.         namaHari = 'Senin';
  12.         break;
  13.     case 3:
  14.         namaHari = 'Selasa';
  15.         break;
  16.     case 4:
  17.         namaHari = 'Rabu';
  18.         break;
  19.     case 5:
  20.         namaHari = 'Kamis';
  21.         break;
  22.     case 6:
  23.         namaHari = 'Jumat';
  24.         break;
  25.     case 7:
  26.         namaHari = 'Sabtu';
  27.         break;
  28.     default:
  29.         namaHari = 'Hari tidak valid';
  30. }
  31. console.log('Hari ini adalah ' + namaHari);
Tags: JavaScript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement