Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to fix my code using eslint and its throwing an error saying:

cName: "" + ANR + "",

Unexpected string concatenation

const ANR = 'Animal Friend,ANR,ANP,$30';

        const specialityPlates = [{
      cName: 'Environmental / Wildlife',
      oSubMenu: [{
        cName: "" + ANR + "",
        cReturn: "" + ANR + "|27.00"
      },
      {

What is wrong with the concatenation in this string?

question from:https://stackoverflow.com/questions/46858840/unexpected-string-concatenation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
206 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try using a template literal.

ie.

const ANR = 'Animal Friend,ANR,ANP,$30'
const specialityPlates = [
  {
    cName: 'Environmental / Wildlife',
    oSubMenu: [{
      cName: `${ANR}`, // "Animal Friend,ANR,ANP,$30"
      cReturn: `${ANR}|27.00` // "Animal Friend,ANR,ANP,$30|27.00"
    }]
  }
]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...