Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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(maskedNumber);
// expected output: "************5581"
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery open a new tab 
Javascript :: javascript add attribute 
Javascript :: copy text to clipboard javascript 
Javascript :: jquery set checkbox checked unchecked 
Javascript :: $(...).autocomplete is not a function 
Javascript :: js reload page 1024 breakpoint 
Javascript :: synchronous ajax 
Javascript :: css in console.log 
Javascript :: javascript median of array 
Javascript :: gdscript yield timer 
Javascript :: node js stop 
Javascript :: google script for loop 
Javascript :: moment today date 
Javascript :: logout in react js 
Javascript :: js math round up 
Javascript :: seconds to hh mm ss javascript 
Javascript :: javascript today minus 1 day 
Javascript :: save on focus lost sublime 
Javascript :: javascript scroll to end of div 
Javascript :: on window resize react 
Javascript :: react native text wrap 
Javascript :: js check if element into view 
Javascript :: jquery set select readonly 
Javascript :: how to open browser for upload with click on element in jquery 
Javascript :: datatable default sorting 
Javascript :: javascript disable enter key 
Javascript :: jquery detect if element has overflow 
Javascript :: javascript string into substrings of length 
Javascript :: react router how to go back 
Javascript :: readable date in javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =