Posts

Showing posts from September, 2023

Day 100: Date Time to Number of 100DaysCodingChallenge

Image
Hello all,  #day100  Day100  Today's my task was to Write a Program to Convert Date and Time to Number. I have started the 100 days of coding  challenge  to improve my programming skills.. Code :  // program to display the date // get local machine date time const date = new Date(); const datetime = Date.now(); // get the date as a string const n = date.toDateString(); // get the time as a string //const time = datetime.toLocalTimeString(); let t = datetime.toString(); let time = date.getTime(); //let dt = time.toLocalTimeString(); // display date console.log('Date: ' + date); // display time //console.log('Time: ' + time); console.log(t); Output :         Happy Coding:)           Day 100 Of 100 Days Coding Challenge Thank you...      

Day 99: Encode String to Base64 Using Object of 100DaysCodingChallenge

Image
Hello all,  #day99  Day99  Today's my task was to Write a Program to Encode a String (input entered by the user) to Base64 using Object. I have started the 100 days of coding  challenge  to improve my programming skills.. Code :  const string = prompt("Enter a String : "); // program to encode a string to Base64 // create Base64 Object const Base64 = { // private property _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode: function(input) { let output = ""; let chr1, chr2, chr3, enc1, enc2, enc3, enc4; let i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 6

Day 98: Compare Two Dates of 100DaysCodingChallenge

Image
Hello all,  #day98  Day98  Today's  my task was to Write a Program to Compare the Two Dates. I have started the 100 days of coding  challenge  to improve my programming skills.. Code :  // program to compare value of two dates // create two dates const d1 = new Date(); const d2 = new Date(); console.log(d1); console.log(d2); // 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 >= d2; console.log(compare4); const compare5 = d1.getTime() === d2.getTime(); console.log(compare5); const compare6 = d1.getTime() !== d2.getTime(); console.log(compare6); Output :         Happy Coding:) Day 98 Of 100 Days Coding Challenge Thank you...      

Day 97: Format the Date and Time of 100DaysCodingChallenge

Image
Hello all,  #day97  Day97  Today's my task was to Write a Program to Display the Format the Date and Time. I have started the 100 days of coding  challenge  to improve my programming skills.. Code :  // program to format the date // get current date let currentDate = new Date(); // get the day from the date let day = currentDate.getDate(); // get the month from the date // + 1 because month starts from 0 let month = currentDate.getMonth() + 1; // get the year from the date let year = currentDate.getFullYear(); // if day is less than 10, add 0 to make consistent format if (day < 10) { day = '0' + day; } // if month is less than 10, add 0 if (month < 10) { month = '0' + month; } // display in various formats const formattedDate1 = month + '/' + day + '/' + year; console.log(formattedDate1); const formattedDate2 = month + '-' + day + '-' + year; console.log(formattedDate2); const formattedDate3 = day + '-' + mo