0
<!DOCTYPE html>

<html>

<head>

<style>




</style>

</head>

<body>

<script>
//variables//
var x = Math.floor((Math.random() * 5) + 1);
var y;

//variable y//
if (x = 1) {
    y = 'javascript';
} else if (x = 2) {
    y = 'html';
} else if (x = 3) {
    y = 'python';
} else if (x = 4) {
    y = 'swedish';
} else if (x = 5) {
    y = 'your choice';
} else {
    y = 'error';
} 
//what should be printed//
document.write('<h3>' + y + '</h3>');
</script>

</body>

I'm trying to make some javascript code that decides what I am going to focus on for the day but it just comes up as "javascript" whenever I try to load it. I could have a bit of code in the wrong or some invalid syntax, I'm not entirely sure what could be wrong because I'm pretty new to javascript.

0 Answers0