• Nov 19, 2022 •CodeCatch
0 likes • 3 views
const euclideanDistance = (a, b) => Math.hypot(...Object.keys(a).map(k => b[k] - a[k])); euclideanDistance([1, 1], [2, 3]); // ~2.2361 euclideanDistance([1, 1, 1], [2, 3, 2]); // ~2.4495
• Nov 18, 2022 •AustinLeath
0 likes • 2 views
var d = new Date(); var d = new Date(milliseconds); var d = new Date(dateString); var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
0 likes • 1 view
//JavaScript program to swap two variables //take input from the users let a = prompt('Enter the first variable: '); let b = prompt('Enter the second variable: '); // XOR operator a = a ^ b b = a ^ b a = a ^ b console.log(`The value of a after swapping: ${a}`); console.log(`The value of b after swapping: ${b}`);
• Feb 21, 2025 •leafboo
console.log("hello world")
0 likes • 0 views
const copyToClipboard = str => { const el = document.createElement('textarea'); el.value = str; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.left = '-9999px'; document.body.appendChild(el); const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; el.select(); document.execCommand('copy'); document.body.removeChild(el); if (selected) { document.getSelection().removeAllRanges(); document.getSelection().addRange(selected); } }; copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard.
• Mar 10, 2022 •LeifMessinger
//Use at https://mee6.xyz/leaderboard/732262089447702588 //Higher the spammy stat, the more spammy that person is. //This is because mee doesn't give experience to people who post more comments in a minute. function statBlock(title, value){ let elm = document.createElement("div"); elm.className = "leaderboardPlayerStatBlock"; let titleElm = document.createElement("div"); titleElm.className = "leaderboardPlayerStatName"; titleElm.textContent = title; let valueElm = document.createElement("div"); valueElm.className = "leaderboardPlayerStatValue"; valueElm.textContent = value; elm.appendChild(titleElm); elm.appendChild(valueElm); elm.remove = function(){ this.parentElement.removeChild(this); } return elm; } for(let player of Array.from(document.getElementsByClassName("leaderboardPlayer"))){ if(player.spamminess) player.spamminess.remove(); let messages = null; let experience = null; const statBlockArray = Array.from(player.querySelectorAll(".leaderboardPlayerStatBlock")); for(let statBlock of statBlockArray){ const statName = statBlock.querySelector(".leaderboardPlayerStatName").textContent; const text = statBlock.querySelector(".leaderboardPlayerStatValue").textContent; const number = ((text.includes("k"))? (text.replace("k","") * 1000.0) : +(text)); if(statName.includes("MESSAGES")){ messages = number; }else if(statName.includes("EXPERIENCE")){ experience = number; } } const stats = player.querySelector(".leaderboardPlayerStats"); const messagesElement = stats.firstChild; const spamminess = ((messages/experience)*2000.0).toFixed(2); player.spamminess = stats.insertBefore(statBlock("SPAMMINESS", spamminess), messagesElement); }