Hello. I the code below is part of an assessment part 4. I cant seem to get the pwdResult to output the else if message. It keeps saying that there is an unexpected else statement which is the else statement for the very first openin if statement.
Also I am aware that the instructions ask me to write the code in one line (using a ternary operator statement?), but I would first like to write it using nested if statement so that I can make sure I undestand the concepts fully.
Can someone please help point me in the right direction.
Here is the link to the assessment.
let machineActive = true;
let pwd = ‘cheese’;
let machineResult;
let pwdResult;
// Add your code here
if (machineActive == true) {
if (pwd = “cheese”)
{
pwdResult = “You have logged in.”
}
else {
pwdResult =“Wrong password”
}}
else
{
machineResult = “The machine is off”
}
// Don’t edit the code below here!
section.innerHTML = ’ ';
let para1 = document.createElement(‘p’);
let para2 = document.createElement(‘p’);
para1.textContent = machineResult;
para2.textContent = pwdResult;
section.appendChild(para1);
section.appendChild(para2);