What seems the problem here? Im using Programiz's Javascript compiler
What seems the problem here? Im using Programiz's Javascript compiler
CODE:
//Print menu
console.log("1: String Concatenation")
console.log("2: String Comparison")
console.log("3: Fibonacci Sequence")
console.log("4: Floyd Triangle")
console.log("5: Quit")
//User input
var n = prompt("Choose one: ");
//Compare choice and perform required operation
switch (n) {
case 1:
var string1 = prompt("Enter the first string: ");
var string2 = prompt("Enter the second string: ");
alert(string1 + string2);
break;
case 2:
var string1 = prompt("Enter the first string: ");
var string2 = prompt("Enter the second string: ");
if (string1 == string2) {
alert("The strings are equal");
} else {
alert("The strings are not equal");
}
break;
case 3:
var n = prompt("Enter the number of terms: ");
var a = 0;
var b = 1;
var c;
alert("The Fibonacci sequence is: ");
alert(a);
alert(b);
for (i = 2; i < n; i++) {
c = a + b;
a = b;
b = c;
alert(c);
}
break;
case 4:
var n = prompt("Enter the number of rows: ");
var num = 1;
alert("The Floyd triangle is: ");
for (i = 1; i <= n; i++) {
for (j = 1; j <= i; j++) {
process.stdout.write(num + " ");
num++;
}
process.stdout.write("\n");
}
break;
case 5:
alert("Thank you!");
break;
default:
alert("Invalid input");
}
![Output
node / tmp/rQnF6Iaccl.js
1: String Concatenation
2: String Comparison
3: Fibonacci Sequence
4: Floyd Triangle
5: Quit
internal/modules/cjs/loader.js:638
throw err;
Error: Cannot find module 'readline-sync'
at Function. Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function. Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/tmp/rQnF6Iaccl.js:8:9)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleload (internal/modules/cjs/loader.js:593:12)
at Function. Module._load (internal/modules/cjs/loader.js:585:3)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F22cb4db7-9ca1-41ef-adfb-b1b96fa922c2%2F6afa8ac0-c8f3-4e78-8aa1-45bd26ce1259%2F2zofflm_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Systems Architecture](https://www.bartleby.com/isbn_cover_images/9781305080195/9781305080195_smallCoverImage.gif)
![Systems Architecture](https://www.bartleby.com/isbn_cover_images/9781305080195/9781305080195_smallCoverImage.gif)