Menu
Coddy logo textTech

15. Palindromic Substrings

Lesson 16 of 31 in Coddy's 30 Days of Logic Building in Javascript course.

challenge icon

Challenge

Medium

Write a function to count the number of palindromic substrings in a string.

  • Input: <strong>"abba"</strong>
  • Output: <strong>6</strong> (a, b, b, a, bb, abba)
  • Input: <strong>"level"</strong> 
  • Output: <strong>7</strong> (l, e, v, e, l, eve, level)

Try it yourself

function countPalindromes(str) {
    // write your code below
    
}

All lessons in 30 Days of Logic Building in Javascript