Created
February 11, 2021 10:18
-
-
Save theDreamer911/fe777e8e35039134607cd1c10b547608 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lifePathNumber(dateOfBirth) { | |
let arr = dateOfBirth.split("-"); | |
let sum = []; | |
const reducer = (accumulator, currentValue) => accumulator + currentValue; | |
for (i = 0; i < arr.length; i++) { | |
for (j = 0; j <= arr[i].length; j++) { | |
if (arr[i][j] == undefined) { | |
arr[i][j] = 0; | |
} else { | |
sum.push(parseInt(arr[i][j])); | |
} | |
} | |
} | |
let sums = sum.reduce(reducer); | |
let checker = sums.toString(); | |
let newSum = []; | |
if (checker.length > 1) { | |
for (i = 0; i < checker.length; i++) { | |
newSum.push(parseInt(checker[i])); | |
} | |
} else { | |
return parseInt(checker); | |
} | |
let newSums = newSum.reduce(reducer); | |
let newChecker = newSums.toString(); | |
let lastSum = []; | |
if (newChecker > 1) { | |
for (i = 0; i < newChecker.length; i++) { | |
lastSum.push(parseInt(newChecker[i])); | |
} | |
} else { | |
return parseInt(newChecker); | |
} | |
return lastSum.reduce(reducer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment