Help with Conditionals 4

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.

Assessment 4

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);

Hi, Nathaniel.
At a first glance, curly braces are well placed? I seem there’s one left over.
Hope this helps you.

@Nathaniel_Rod You are very close to having a working example. It worked for me, except that in this line:

if (pwd = "cheese")

You are using the assignment operator, not the equality operator that is needed to perform the test. It should be this:

if (pwd === "cheese")

A very common mistake, so don’t worry about it.