HAHAHHAHAHHAHHAHAH wtf am I doing ughhh:
function persistence(num) {
let firstP = 0;
let secondP = 0;
let thirdP = 0;
let fourthP = 0;
if ( num.length === 1 ) {
return 0;
} else if ( num.length === 2 ) {
return firstP += num[0]*num[1]
} else if ( num.length === 3 ) {
return firstP += num[0]*num[1]*num[2]
} else if ( num.length === 4 ) {
return firstP += num[0]*num[1]*num[2]*num[3]
}
if ( firstP.length === 1 ) {
return 1;
} else if ( firstP.length === 2 ) {
secondP += firstP[0]*firstP[1]
} else if ( firstP.length === 3 ) {
secondP += firstP[0]*firstP[1]*firstP[2]
} else if ( firstP.length === 4 ) {
secondP += firstP[0]*firstP[1]*firstP[2]*firstP[3]
}
if ( secondP.length === 1 ) {
return 2;
} else if ( secondP.length === 2 ) {
thirdP += secondP[0]*secondP[1]
} else if ( secondP.length === 3 ) {
thirdP += secondP[0]*secondP[1]*secondP[2]
} else if ( secondP.length === 4 ) {
thirdP += secondP[0]*secondP[1]*secondP[2]*secondP[3]
}
if ( thirdP.length === 1 ) {
return 3;
} else if ( thirdP.length === 2 ) {
fourthP += thirdP[0]*thirdP[1]
} else if ( thirdP.length === 3 ) {
fourthP += thirdP[0]*thirdP[1]*thirdP[2]
} else if ( thirdP.length === 4 ) {
fourthP += thirdP[0]*thirdP[1]*thirdP[2]*thirdP[3]
}
if ( fourthP.length === 1 ) {
return 4;
}
}