Shreyas arya

Generation

generate functionFri, 10 Feb 2023

Create a method print a string If type is not string then throw exception and retrun exception and retry 3 times

Script function printString(str) { if (typeof(str) === 'string') { return str } else { throw "string needed" } } try{ printString("hello") } catch(err){ console.log("error", err) }

Questions about programming?Chat with your personal AI assistant