Program JavaScript untuk Membandingkan Elemen Dua Array

Contoh 1: Bandingkan Array Menggunakan JSON.stringify() // program to compare two arrays function compareArrays(arr1, arr2) { // compare arrays const result = JSON.stringify(arr1) == JSON.stringify(arr2) // if result is true if(result) { console.log(‘The arrays have the same elements.’); } else { console.log(‘The arrays have different elements.’); } } const array1 = [1, 3, 5, 8]; […]

Read more »

Program JavaScript untuk Membandingkan Nilai Dua Tanggal

Contoh: Bandingkan Nilai Dua Tanggal // program to compare value of two dates // create two dates const d1 = new Date(); const d2 = new Date(); // comparisons const compare1 = d1 < d2; console.log(compare1); const compare2 = d1 > d2; console.log(compare2); const compare3 = d1 <= d2; console.log(compare3); const compare4 = d1 >= […]

Read more »