Shreyas arya

Generation

generate functionFri, 10 Feb 2023

Create a method to throw an exception if does not print a string

Script function check_string(s) { if (typeof s !== 'string') { throw new Error("It's not a string!") } console.log(s) } check_string(2) // It's not a string! check_string("Hello World") // Hello World

Questions about programming?Chat with your personal AI assistant