I am trying to make text singular or plural based on the value of templateCount. If templateCount's value is 1 then I just want 'Template' to say that, but if templateCount is plural, I want it to say 'Templates Selected'.
What am I doing wrong with my code?
$('#templateCount').html(templateCount + " Templates Selected" + templateCount.length == 1 ? "" : "s");
Are you sure you thought this through? You have the string "Templates selected" there and you are conditionally appending s to the end of that (which would make it "Templates Selecteds").
Do this:
$('#templateCount').html(templateCount +
" Template" +
(templateCount === 1 ? "" : "s") +
" Selected");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With