Assignment JS5: Boolean Expressions



Upload the written answers to Parts 1-3.

Part 1: Logical Operators

For the questions below, assume that p, q, and r are boolean expressions with the values true, true, and false, respectively. Find the value of each boolean expression.
  1. p && !q
  2. p && q || !r
  3. p && ! (q || r)
  4. !p && q
  5. p || q && r




Part 2: Relational Operators !, < ,>, <= ,>= , === , !==



Assume the following variables have been declared:

  let   m  = -5;
  let   n   = 8 ;
  let   x  = -3;
  let   y  = 0.0;
  let   z  = 4;


For the questions below, find the value of the boolean expressions.

  1. m <= n
  2. -2 * m <= 8
  3. x <= y && y <=z
  4. ! (x < y)
  5. 0 <= m <=10
  6. 0 <= m && m <=10




Part 3: Practice Writing Boolean Expressions

For the questions below, assume that p, q, and r are boolean expressions with the values true, true, and false, respectively. Find the value of each boolean expression.
  1. Write a boolean expression to express that x is nonzero.
  2. Write a boolean expression to express that x is strictly between -10 and 10.
  3. Write a boolean expression to express that both x and y are positive or both x and y are negative.