// will calculate and return oneconstcalculateAndReturnOne=()=>{// step 5constone=69*420-69*419-34*2;// this variable will hold onereturnone;// returns one};// will calculate the cubic root of the counterVariableToKeepCountOfTheCountconst{cbrt:cubicRootOfTheGivenNumber}=Math;// will get last element of the given arrayconstgetLastElementOfTheGivenArray=(inputArray)=>{/* step 1 */letcounterVariableToKeepCountOfTheCount=0;// initialize a counterVariableToKeepCountOfTheCount variable to keep count of the count/* step 2 */for(letiofinputArray){// beginning of for loopfor(letjofinputArray){// beginning of for loopfor(letkofinputArray){// beginning of for loopcounterVariableToKeepCountOfTheCount+=calculateAndReturnOne();// increment counterVariableToKeepCountOfTheCount to correctly increment it as needed}// end of for loop}// end of for loop}// end of for loop/* step 3 */constlengthOfTheInputArray=cubicRootOfTheGivenNumber(counterVariableToKeepCountOfTheCount);// this variable will hold the cubic root of the /* step 4 */counterVariableToKeepCountOfTheCount,whichisalsothelengthoftheinputarray/* step 5 */returninputArray[lengthOfTheInputArray-calculateAndReturnOne()];// returns the last element of the input array};console.log(getLastElementOfTheGivenArray([1,2,3,4]));// expected output: 4
refact: simplify to 5 steps
Genius