Tag Archives: Dengan

Membuat Aplikasi Pertama dengan Flutter di Android Studio

https://codingrakitan.blogspot.com/2021/03/membuat-aplikasi-pertama-dengan-flutter.html   Pada tutorial Flutter kali ini kita akan membuat aplikasi pertama dengan menggunakan editor Android Studio. Langsung saja tanpa basa basi silahkan ikuti langkah dibawah ini : 1. Pilih Start a new Flutter project pada jendela awal Android Studio. 2. Pada jendela selanjutnya pilih Flutter Application 3. Isi Project name dengan “hello_world” (nama project […]

Program JavaScript Untuk Bekerja Dengan Konstanta

Contoh: Bekerja Dengan Konstanta // program to include constants const a = 5; console.log(a); // constants are block-scoped { const a = 50; console.log(a); } console.log(a); const arr = [‘work’, ‘exercise’, ‘eat’]; console.log(arr); // add elements to arr array arr[3] = ‘hello’; console.log(arr); // the following code gives error // changing the value of a […]

Program JavaScript untuk Mengganti Semua Line Breaks dengan

Contoh 1: Ganti Semua Line Breaks Menggunakan RegEx // program to replace all line breaks in a string with <br> const string = `I am Learning JavaScript. JavaScript is fun. JavaScript is easy.`; const result = string.replace(/(rn|r|n)/g, ‘<br>’); console.log(result); Keluaran I am Learning JavaScript.<br>JavaScript is fun.<br>JavaScript is easy. Dalam contoh di atas: RegEx digunakan dengan […]

Program JavaScript untuk Memeriksa apakah sebuah String Dimulai Dengan String Lain

Contoh 1: Menggunakan startWith() // program to check if a string starts with another string const string = ‘hello world’; const toCheckString = ‘he’; if(string.startsWith(toCheckString)) { console.warn(‘The string starts with “he”.’); } else { console.warn(`The string does not starts with “he”.`); } Keluaran The string starts with “he”. Pada program di atas, startsWith() metode yang […]

Program JavaScript untuk Memeriksa Apakah String Dimulai dan Diakhiri Dengan Karakter Tertentu

Contoh 1: Periksa String Menggunakan Metode Bawaan // program to check if a string starts with ‘S’ and ends with ‘G’ function checkString(str) { // check if the string starts with S and ends with G if(str.startsWith(‘S’) && str.endsWith(‘G’)) { console.log(‘The string starts with S and ends with G’); } else if(str.startsWith(‘S’)) { console.log(‘The string […]

Program JavaScript untuk Membuat Objek dengan Cara Berbeda

Anda dapat membuat objek dengan tiga cara berbeda: Menggunakan objek literal Dengan membuat instance Object secara langsung Dengan menggunakan fungsi konstruktor Contoh 1: Menggunakan objek literal // program to create JavaScript object using object literal const person = { name: ‘John’, age: 20, hobbies: [‘reading’, ‘games’, ‘coding’], greet: function() { console.log(‘Hello everyone.’); }, score: { […]

Program JavaScript untuk Memeriksa Nomor Armstrong (dengan Contoh)

Bilangan bulat positif disebut bilangan Armstrong (berorde n) jika abcd… = an + bn + cn + dn + … Dalam kasus bilangan Armstrong 3 digit, jumlah pangkat tiga dari setiap digit sama dengan bilangan itu sendiri. Sebagai contoh, 153 adalah nomor Armstrong karena 153 = 1*1*1 + 5*5*5 + 3*3*3 Demikian pula, 1634 adalah […]

Program JavaScript untuk Mencetak Urutan Fibonacci (dengan Contoh)

Urutan fibonacci ditulis sebagai: 0, 1, 1, 2, 3, 5, 8, 13, 21, … Deret Fibonacci adalah deret bilangan bulat di mana dua suku pertama berada 0 dan 1. Setelah itu, suku berikutnya diartikan sebagai penjumlahan dari dua suku sebelumnya. Contoh 1: Seri Fibonacci Hingga n Ketentuan // program to generate fibonacci series up to […]

Program JavaScript untuk Menampilkan Tabel Perkalian (dengan Contoh)

Contoh 1: Tabel Perkalian Hingga 10 // program to generate a multiplication table // take input from the user const number = parseInt(prompt(‘Enter an integer: ‘)); //creating a multiplication table for(let i = 1; i <= 10; i++) { // multiply i with number const result = i * number; // display the result console.log(`${number} […]

Program JavaScript untuk Menemukan Faktorial sebuah Angka (dengan Contoh)

Faktorial sebuah bilangan adalah hasil kali dari semua bilangan asal 1 ke nomor itu. Sebagai contoh, faktorial dari 5 adalah sama dengan 1 * 2 * 3 * 4 * 5 = 120. Faktorial bilangan positif n diberikan oleh: factorial of n (n!) = 1 * 2 * 3 * 4…..n Faktorial bilangan negatif tidak […]