JavaScript: Modify the provided JS file to force each of the JS error types to occur. Catch each error and log a message detailing which error type you triggered.
/*
* Force each of the follow error types to occur
* and catch them. Log a message describing each
* of the error types.
*
* Error types:
* -SyntaxError (already done)
* -ReferenceError
* -TypeError
* -RangeError
*
* Additionally, throw your own error with a
* custom error message containing your name.
* Catch your error and log a message.
*/
console.log('
try {
JSON.parse(`{name: 'John', age: 18}`);
} catch(error) {
console.log(`Caught a syntax error: `);
console.log(error);
}
// CODE STARTS HERE
// CODE ENDS HERE
console.log('PROGRAM END');
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. // Application looks up home price // for different floor plans // allows upper or lowercase data entry import java.util.*; public class DebugEight3 { publicstaticvoidmain(String[] args) { Scanner input =newScanner(System.in); String entry; char[] floorPlans = {'A','B','C','a','b','c'} int[] pricesInThousands = {145,190,235}; char plan; int x, fp =99; String prompt ="Please select a floor plan\n"+ "Our floorPlanss are:\n"+"A - Augusta, a ranch\n"+ "B - Brittany, a split level\n"+ "C - Colonial, a two-story\n"+ "Enter floorPlans letter"; System.out.println(prompt); entry = input.next(); plan = entry.charAt(1); for(x =0; x < floorPlans.length; ++x) if(plan == floorPlans[x]) x = fp; if(fp =99) System.out.println("Invalid floor plan code entered")); else { if(fp…arrow_forwardnew java code can only be added after line 17.arrow_forwardThis code is only for python. this is a game- transfer rings there are 3 problems which you are solving: A: failed transfer - make sure the progam dont take more than what the user inputed by raising an exceptionB: codE the trade_money function C: if sonic doesnt have as much as the user inputed, there will be an error pop up 'ERROR TRADE FAILED'. make it so the progam can run normally rather than turning it down. CODE: class user:def __init__(self, name, initial_money):self.name = nameself.money = initial_moneydef give_money(self, amount):self.money = self.money + amountdef take_money(self, amount):# Part A: Raise an exception as appropriateself.money = self.money - amountdef print_users(users):total_money = 0for user in users:print(f'{user.name:s} has {user.money:d} rings')total_money = total_money + user.moneyprint(f'There are a total of {total_money:d} rings')# B: code the trade_money functionsonic = user('sonic', 80)tails = user('tails', 20)print_users([sonic,…arrow_forward
- Shell Scripting: Write the output when the input is 40: echo -n "Enter any number:" read n if [ $n -eq 30 ] 11 [ $n -gt 50 ] then echo "1" else echo "2" fiarrow_forwardIn a catch block, there is no limit to the amount of arguments that may be used.arrow_forwardArguments to a catch block are not restricted in number.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education