Passing a variable as a string how.. can I do it

ccc=3
some function()
    {
        this.ccc+=1
     //   let xx=this.ccc.toString()
        let xxx= 'egg'+`${xx}`
        console.log(xxx)
     
    console.log('hello')
    }

Yes I thought I knew this I tried a couple of different things but console log statement comes back
eggNAN I forgot or something how to pass it right it is supposed to be a string ‘egg4’ what am I missing
feel free to help =|

Hi! Your code has a few problems. You should no refer to a global variable with this when not working with objects. It will most probably give you an unexpected result.

Take a look in the code below and see if it helps to clarify:

function some(str) {
	return `egg${ccc}`;
}

Yes it is in a Class, your example is correct but “ccc” is undefined when calling the Class…
If I set it in the function, it will never increment beyond 4… since i set it every call… I’m not good at this but… it doesn’t help to set value in constructor either I’m clueless. =/

Could you share the whole exercise?