reading-notes

Operator and Loops

For Loops

Operators

Assignment Operators

assignment operators or simply “=”

it assigns whatever is to the right of it to whatever is to the left of it

Example:

function getuserName(){ let userName = prompt('please enter your name:'); console.log(userName); user1= userName return (userName); }

whatever the user puts as their username becomes user1 and it returns their user name in the webpage.

Comparison Operators

or simply put “double equal sign” compares whatever is to the right and left of it and makes sure they are true

for example:

function getuserAnswer(){
let userAnswer = prompt('DO you like MMA?:')
console.log(userAnswer);

if (userAnswer.toLowerCase() == 'yes') {
    document.write('<h3>Welcome ' + user1 +'</h3>') ;
} else {
    document.write('<h3>' + user1 +' , you should try it out</h3>');
}

in the example its going to compare whatever the users answer is to my question if its a “yes” it spits out a welcome message. if it is something else it will spit out the message try it out. if they answer no for example, the comparison of yes is FALSE.