Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

then and catch in promise

try {
   let hello = prompt(“Type hello”)
   if (hello !== ‘hello’){
     throw new Error(“Oops, you didn’t type hello”)
   }
} catch(e) {
   alert(e.message)
} finally {
   alert(‘thanks for playing!’)
}
Source by lucymarmitchell.medium.com #
 
PREVIOUS NEXT
Tagged: #catch #promise
ADD COMMENT
Topic
Name
6+7 =