JavaScript pluralize an english string

前端 未结 11 1010
南旧
南旧 2020-12-23 16:24

In PHP, I use Kuwamoto\'s class to pluralize nouns in my strings. I didn\'t find something as good as this script in javascript except for some plugins. So, it would be grea

11条回答
  •  伪装坚强ぢ
    2020-12-23 16:53

    I use this simple inline statement

    const number = 2;
    const string = `${number} trutle${number === 1 ? "" : "s"}`; //this one
    console.log(string)

提交回复
热议问题