Figure it's only fair to throw my answer into the ring. Clearly very novice and verbose 😇. Added a number of comments for the other #beginners out there.
varkap=function(number){varwhole=number.toString();// convert number to stringif(whole.length%2!==0){// if the length is odd, add a zero to the frontwhole="0"+whole;// IE 123 becomes 0123}varmiddle=whole.length/2;// find the index of the middle and end of the stringvarend=whole.length;varpiece1=whole.slice(0,middle);// break it into two piecesvarpiece2=whole.slice(middle,end);piece1=parseInt(piece1);// convert back to numberspiece2=parseInt(piece2);varfinal=piece1+piece2;// add them togetherreturnfinal;// return result}for(i=1;i<1000;i++){// simple for loop from 1 to 1,000varsquared=i*i;varkapval=kap(squared);if(i==kapval){// sees if they matchconsole.log(i);}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Figure it's only fair to throw my answer into the ring. Clearly very novice and verbose 😇. Added a number of comments for the other #beginners out there.