• Mwa
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    2
    ·
    3 months ago

    if javascript can do it,tell me how to do it?

    • jtrek@startrek.website
      link
      fedilink
      arrow-up
      3
      ·
      3 months ago
      
      const countOfT = (word) => word.split('').filter(i => i === 't').length
      countOfT('colonialism')
      0 
      
      countOfT('this is an example sentence')
      2 
      

      There’s probably a more elegant way to do it.

      • Mwa
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        3 months ago

        nice to know that does not need AI ig