count number of palindromes till n in javascript