Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

to put dash between two even numbers in number

function insertHyphen(str) {
  var strArr = str.split('');
  var numArr = strArr.map(Number);
  for(var i = 0; i < numArr.length; i++) {
   if(numArr[i-1]%2===0 && numArr[i]%2===0) {
        numArr.push('-');
    }
  }
  return numArr.join('');
}
insertHyphen('112233445566'); // 112233445566---
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular file upload app with django 
Javascript :: lemon get node from id 
Javascript :: pdfjs add custom event handler to viewer.js 
Javascript :: Why is #_=_ appended to the redirect URI? passport facebook 
Javascript :: react html symbol code 
Javascript :: select coordinates of image 
Javascript :: jQuery exclude exteranl link for images 
Javascript :: apply event listener on id but why not style 
Javascript :: advanced data manipulation javascript 
Javascript :: time second updating without rendering 
Javascript :: ar.js getting started 
Javascript :: js packages 
Javascript :: new activexobject( adodb.connection ) javascript 
Javascript :: node-emoji list 
Javascript :: mvc set javascript variable from model 
Javascript :: jquery automatically click message alert 
Javascript :: jhow to make a fish in javascript 
Javascript :: python config file json datatypes 
Javascript :: javascript alert program 
Javascript :: how to update value in nested json using id in javascript 
Javascript :: total cost example in javascript with function 
Javascript :: jquery post data into an iframe from textarea live 
Javascript :: what does conservatism really mean 
Javascript :: get image center pixels nodejs 
Javascript :: how to change style class by using onclick function with multiple buttons in react js 
Javascript :: video pop js 
Javascript :: media query for mobile in react file 
Javascript :: chartJS Timeline with images 
Javascript :: how to auto click webpage in angular 
Javascript :: json report plugin 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =