function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Satyam K.Satyam K. 

Parsing error: Unexpected token, expected ";"

In Build a Bear-Tracking App with Lightning Web Components, I am getting error  Parsing error: Unexpected token, expected ";". Can't find out whats wrong.

VS Code Screenshot
Best Answer chosen by Satyam K.
Deepali KulshresthaDeepali Kulshrestha
Hi Satyam,
Greetings to you!

- Please use the below code for further reference: -
 
export default class HelloWebComponent extends LightningElement {
        @track greeting='Trailblazer';
          handleGreetingChange(event) {
                this.greeting = event.target.value;
                currentDate = new Date().toDateString();
          }
          get capitalizedGreeting() {
               return `Hello ${this.greeting.toUpperCase()}!`;
          }
        }
    }



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.

All Answers

Ajay K DubediAjay K Dubedi
Hi Satyam,

Try the following:
1. Try replacing both ` with ', it looks like return 'Hello ${this.greeting.toUpperCase()}!'; , if it still doesn't then,
2. Then try adding concatnation symbols '+' after hello and before '!'. Like: return 'Hello+ ${this.greeting.toUpperCase()}+!';

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi
Satyam K.Satyam K.
Thanks Ajay for help. But that was not the error.
The error was in the place where i was pasting the code.

This code worked for me:

import { LightningElement, track} from 'lwc';
    
export default class HelloWebComponent extends LightningElement {
@track greeting = 'Trailblazer';
handleGreetingChange(event) {
this.greeting = event.target.value;
}
currentDate = new Date().toDateString();
get capitalizedGreeting(){
return `Hello ${this.greeting.toUpperCase()}!`;
}
}
Deepali KulshresthaDeepali Kulshrestha
Hi Satyam,
Greetings to you!

- Please use the below code for further reference: -
 
export default class HelloWebComponent extends LightningElement {
        @track greeting='Trailblazer';
          handleGreetingChange(event) {
                this.greeting = event.target.value;
                currentDate = new Date().toDateString();
          }
          get capitalizedGreeting() {
               return `Hello ${this.greeting.toUpperCase()}!`;
          }
        }
    }



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.
This was selected as the best answer
Shivanand Medam 2Shivanand Medam 2
import { LightningElement, track } from 'lwc';
export default class HelloWebComponent extends LightningElement {
    @track greeting = 'Trailblazer';
    currentdate = new Date().toDateString();
    handlegreetingchange(event){
        this.greeting = event.target.value;
        
    }
    get capitalizedgreeting() {
        return `Hello ${this.greeting.toUpperCase()}!`;
   }