What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-15 15:38:02
how to pad string js
const str1 = '5'; console.log(str1.padStart(2, '0')); // expected output: "05" const fullNumber = '2034399002125581'; const last4Digits = fullNumber.slice(-4); const maskedNumber = last4Digits.padStart(fullNumber.length, '*'); console.log(mas... Add solution -
Javascript 2021-09-15 07:06:06
uppercase in word javascript
//capitalize only the first letter of the string. function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } //capitalize all words of a string. function capitalizeWords(string) { return string.repl... Add solution -
Javascript 2021-09-15 00:57:04
javascript get main color from image
const canvas = document.getElementById("canvas"), preview = document.getElementById("preview"), ctx = canvas.getContext("2d"); canvas.width = 1; canvas.height = 1; preview.width = 400; preview.height = 400; function ge... Add solution -
Javascript 2021-09-15 00:19:03
javascript rgb to hex
function rgbToHex(r, g, b) { return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); } function hexToRgb(hex) { var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); if(result){ var... Add solution