Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Count recurring digits in number

const createObjectFromNumber = (num) => {
  let object = {};
  while (num > 0) {
    let remains = Math.floor(num / 10);
    let temp = num - remains * 10;
    object[temp] = object[temp] ? object[temp] + 1 : 1;
    num = remains;
  }
  return object;
};
 
PREVIOUS NEXT
Tagged: #Count #recurring #digits #number
ADD COMMENT
Topic
Name
3+7 =