Skip to content

Instantly share code, notes, and snippets.

View subodhrathaur's full-sized avatar
🏠
Working from home

Subodh Rathaur subodhrathaur

🏠
Working from home
View GitHub Profile
let inputParam = 'abccbdeedfgg';
const findRepeatingCharacters = (val) => {
let outputArray = [];
let temp = '';
for (const element of val) {
if (temp !== '') {
if (temp === element) {
function getDayDiff(start, end) {
let startDate = new Date(start);
let endDate = new Date(end);
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
throw new Error("Invalid date provided.");
}
let difference = Math.abs(endDate - startDate);
let days = difference / (1000 * 60 * 60 * 24);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mouse Scroll Event</title>
</head>
<body>
<div style="height: 2000px; padding: 20px;">
<h1>Scroll the page</h1>
function currying(x){
return function (y){
console.log(x+y);
}
}
currying(9)(4)
@subodhrathaur
subodhrathaur / prime_number_finder.js
Last active December 4, 2024 15:19
Prime Number Finder
const isPrime = (num) => {
if (num <= 1) {
return false;
}
for (let index = 2; index <= Math.sqrt(num); index++) {
@subodhrathaur
subodhrathaur / timed_execution_logger.js
Last active December 4, 2024 15:15
Timed Execution Logger
const steps = (timeInSec) => new Promise((resolve, reject) => setTimeout(() => { resolve(); }, timeInSec * 1000));
async function breakFunction() {
console.log('Initial Logging...');
await steps(2);
console.log('2 seconds break completed...');
await steps(3);
console.log('3 seconds break completed...');