score:1

Accepted answer

seems that keyword this is ambigous, as soon as newuserdocs is defined as variable you can access is without this. portion as soon as context for this is unclear in your example:

if(this.newuserdocs.username === "test"){
  console.log('the username is good');
} 

upd: js is case sensitive. your variable is called newuserdocs (lower-case u) and then your access it by newuserdocs (upper-case u). try newuserdocs.username

score:1

i run this, it works perfect. you missed:

  1. you have to approach the variable without use this..
  2. the spelling of the const.

    const newuserdocs = {username:"test", name:"testname"};
    
    console.log(newuserdocs);
    
    if(newuserdocs.username === "test"){
      console.log('the username is good');
    } 
    

enter image description here

i hope it helps you.


Related Query

More Query from same tag