Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

codewars playing with digits js

function digPow(n, p){
    let digitSum = 0;
    let strNum = String(n);
    for(let i in strNum){
      digitSum += strNum[i]**p;
      p++;
    }
    return Number.isInteger(digitSum/n) ? digitSum/n : -1;
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript get bounding rect 
Javascript :: Javascript remove array item by value 
Javascript :: javascript get last element of array 
Javascript :: javvascript convert boolean to string 
Javascript :: Node Sass version 5.0.0 is incompatible with ^4.0.0. 
Javascript :: reapeat until in js 
Javascript :: javascript check if first of type 
Javascript :: opal find element 
Javascript :: discord bot steaming satus 
Javascript :: Codewars hello world 
Javascript :: javascript get a random number with 6 digits 
Javascript :: demo json data 
Javascript :: within range js 
Javascript :: remove backslash in json array javascript 
Javascript :: jquery on modal show 
Javascript :: how to format money as currency string 
Javascript :: how to get current year in javascript 
Javascript :: get how much i scroll in js 
Javascript :: how to get the contract address from the contract instance web3js 
Javascript :: js take last item in array 
Javascript :: js loop through object 
Javascript :: javascript find object by property in array 
Javascript :: mongoose generate new ObjectID 
Javascript :: gdscript emit signal 
Javascript :: ajax redirect in success 
Javascript :: javascript add class to all child elements 
Javascript :: jquery get top position of element on scroll 
Javascript :: check if it is a function javascript 
Javascript :: Fancybox 2 popup show no of images counter 
Javascript :: javascript date to hours minutes seconds 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =