functionreverseInteger(n:number):number{returnNumber(String(n).split('').reverse().join(''));}functionisPalindrome(num:number):boolean{if(num===reverseInteger(num)){returntrue;}returnfalse;}// I had this in separate files sorry if its confusing X)import{max}from'mathjs';letnumber=0;leta=999;constpalindromes:number[]=[];while(a>1){for(leti=2;i<=999;i+=1){number=a*i;if(isPalindrome(number)){palindromes.push(number);}}a-=1;}console.log(`Max palindrome ${max(...palindromes)}`);
My typescript solution:
Please don't do this 😕 It's verbose for no reason. You can accomplish the same with just
return condition;
.cool! yes so much simple
thanks!