Prompt is not working

This is the codepen above. i have done this before. Why is my prompt coming up?
Here is the JS Code!

let computer = prompt(“What kind of Computer do you have(Windows 32Bit, Mac 32Bit, Windows 64Bit or Mac 64Bit)?”);

if (computer === “Windows 32Bit”){
let = prompt(“Check out Puppy Linux or Linux Mint Cinnamon!”);
alert (“Check out Puppy Linux or Linux Mint Cinnamon! It feels just like windows!”);

}if (computer === “Mac 32Bit”)
alert (“Your :computer: Mac 32 bit is perfect for lighweight Linux debian distros under 600mb like Xubuntu, Zorin Os Lite, Bodhi Linux and Linux Lite!”);

}if (computer === “Mac 64Bit”){
alert (“Your :computer: Mac 64 bit can install all Linux distros in a 64-bit variant. You can try Mint XFCE!”);

}else 

alert (“Your :computer: Windows 64 bit can install all Linux distros. Check out Puppy Linux or Linux Mint Cinnamon!”);

maybe CodePen doesn’t allow the prompt?

I think you don’t need this prompt as you didn’t give it any variable name and its text is already used in alert on the line below. So you can delete it.

You missed the opening curly braces for your if condition.


It would work but not as you might expect cause if you try to input Windows 32Bit for example you would notice that the alert message in the else is also executed.

This is because you used multiple if statements and that else is only tied to the last if which its condition is computer === "Mac 64Bit", this is the only input that the else’s alert will not be shown.

To fix this you can use if, else if and then on the very last use your else.
That way, what is in your else will get executed only when there is no matching in all previous conditions which i think this is what you want.

There are several issues here:

First, you are redefining the computer and bitrate variables after prompting the user for input. This will prevent the prompt from appearing on the screen. Instead, you should only declare these variables once and assign them the values returned by prompt().

let computer = prompt("What kind of computer do you have (Windows or Mac)?");
let bitrate = prompt("What bitrate does it have (32Bit or 64Bit)?");

Second, in your if condition, you should check both computer and bitrate values separately using logical operators (&&). This ensures that both conditions are met before executing the alert or you can make different control for user input. But user can write anything HTML radio input will be more accurete.

if (computer === "Windows" && "32Bit") {
  alert ("Check out Ubuntu Linux or Linux Mint Faye for your "( + computer + )"! It feels just like windows and it has got only little mb!");  
   }

Lastly, using parentheses around the + operator in your alert message, these parentheses are not necessary, using them cause a syntax error.

For more information on JavaScript syntax and conditionals, you can refer to the
If Statement
Prompt
Radio input
InnerHTML
Dom manupulation

Actually, all of that quite well explained in this curriculum. However, using prompt is not recommended for taking input from users in modern web applications. It’s better to use other input methods or form elements for a better user experience.

Here’s a working sample of your code. However, keep in mind that if the user enters “windows 11” or “x86”, it will not work as expected. You may need to implement additional checks, possibly using regular expressions, to handle various inputs more robustly.

let computer = prompt("What kind of computer do you have (Windows or Mac)?");
let bitrate = prompt("What bitrate does it have (32Bit or 64Bit)?");


if (computer === "Windows" && bitrate === "32Bit") {
  alert("Check out Ubuntu Linux or Linux Mint for your " + computer + "! It feels just like Windows and uses minimal resources.");
} else if (computer === "Windows" && bitrate === "64Bit") {
  alert("Do you consider your " + computer + " to newer macOS?");
} else if (computer === "Mac" && bitrate === "32Bit") {
  alert("Upgrade to a newer version of macOS for improved performance and security.");
} else if (computer === "Mac" && bitrate === "64Bit") {
  alert("Your " + computer + " is capable of running the latest macOS version smoothly.");
} else {
  alert("Invalid input. Please provide valid answers.");
}