Uncaught SyntaxError: Unexpected end of input,javascript promise chaining

I’m doing javascript promises and I encountered an syntax error .my code is below

    let p = new Promise(function(resolve,reject){
   let workDone = "hello world"; 
      if(workDone=="hello world"){
      
      
	  resolve('promise completed')
   }
   else{
      reject(' work could not be completed')
   }
})




.then(result => doSomethingElse("I"+result))
.then(newResult => doThirdThing("am"+newResult))
.then(finalResult => console.log("Javascript"+finalResult))
.catch((error)=>{
       console.log("error result",error);

error is

Uncaught SyntaxError: Unexpected end of input

Please correct the code .

Thanks
:slight_smile:

I got the output for above code . My new code

 function print() {
      let p = new Promise(function (resolve, reject) {
        let work="hello world";
         if (work="hello world") {
            
            resolve('success')
         }
         else
            reject('failed')
      })
      return p;
   }

   print()
   .then(function(result){
      console.log("I")
      return print(result)
   }).then(function(result){
   console.log("am")
      return print(result)
   }).then(function(result){
      console.log("Javascript",result)
   }).catch((error)=>{
       console.log("error result",error)
       
       })



   console.log('end')

output:

end
 I
am
Javascript success

Edit: If you still feel there is error in code or output,the code could have been better .
Please feel free to correct me.
Thanks :slight_smile: