Shreyas arya

Generation

generate functionFri, 10 Feb 2023

Create a method print a string If type is not string then throw exception

Script function printString(str) { if(typeof str !== "string") { throw new Error("string expected"); } console.log(str); } printString("hello"); printString(1);

Questions about programming?Chat with your personal AI assistant