Showing posts with label Operators. Show all posts
Showing posts with label Operators. Show all posts

JavaScript Logical Operators (and Boolean)

  • && (AND)
  • || (OR)
  • ! (NOT)
If you were to find out if two values were true or false, you would use AND. 

For something to be true, both the values would have to be true. 

For example, requesting if:

true && true = true
true && false = false
false && false = false 

|| (OR) is requesting if one of the values is true. For example: 

true || fsadf = true
false || true = true
false || false = false 

! (NOT) is a negation, so requesting if:
!true = false (something not true is false)
!false = true (something not false is true)

You can also combine logical operators.  For example:
 !(true && true) = false (because true AND true is true, and negating it is false) 

For more on operators, go to https://jamesymcjamesface.blogspot.com/2020/04/javascript-operators.html

JavaScript Operators

With JavaScript, a number is just a number (unlike in Python where you have integers, float and complex numbers).

The operators that can be used with numbers in JavaScript are:
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus (the remainders from division).

Note: if you say:
var x = 5
var y = 3
x + y  = 8

But if you say:
var "x" = 5
var "y" = 3
x + y = 53

In the latter, it returns 53, because you have defined x and y as strings by placing them in quotation marks.

There are other special variable operators: 
++ (This will increment the variable by 1): x = 5... x ++ = 6
-- (This will decrease the variable by 1): x = 5... x-- = 4

Comparisons:
== (equal to)
=== (equal value and type) this is unique to Javascript, and will return if the var is equal in number and type.  For example, if  you ask if "5" === 5, it will return 'false' as one is a string and the other is a number. However, if you ask if "5"==5, it will return 'true' despite the fact that they are different types.
!= (not equal to)
!== (not equal value or not equal type)
> (greater than)
>= (greater than or equal to)
< (less than)
<= (less than or equal to)

See about JavaScript logical operators at https://jamesymcjamesface.blogspot.com/2020/04/javascript-logical-operators-and-boolean.html

Web Development: Organizing Files and Folders

When you begin to build your website, it's a very clever idea to organize  your files and folders efficiently. You should have: A ...