Question
Hi, i ahve this typescript program but whenever I run the program i get this error message below can you help me fix it error:
Hi, i ahve this typescript program but whenever I run the program i get this error message below can you help me fix it
error:
code:
'use strict'; import * as readline from 'readline';
let inputHandler = readline.createInterface({ input: process.stdin, output: process.stdout });
// Function to print pattern recursively function printPattern(integer: number) { if (integer = 5) { return (printPattern(integer - 1) + " " + integer + printPattern(integer - 1) + " " + " "); } else { return (printPattern(integer - 1) + " " + integer + printPattern(integer - 1)); } } }
// getting user input from the console inputHandler.question("Enter a number between 1 to 15: ", (answer: string) => { // parsing the string input let integerAnswer: number = parseInt(answer, 10); // performing the pattern if (integerAnswer 15) { console.log("Error: Wrong input"); } else { console.log("User input | Program output " + integerAnswer + " | " + printPattern(integerAnswer) + " "); } // closing the handler inputHandler.close(); })
TSError:Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started