CPSI 20023 HW3 Due by Wednesday Sept. 17, 2025
Directions: Answer the questions below, then hand in by emailing to CPSI20023@gmail.com. Please avoid sending a link to a shared google doc, because the grader might not be able to access it. You may use JavaScript, reasoning, or both. Sometimes, the best way is to try to reason them out, then try them in JavaScript to check your reasoning. You can use a sandbox to test JavaScript statement.
(1) Give four examples of the logical OR (written in JavaScript as ||) from daily life illustrating the four cases of true or false, false or true, true or true, and false or false. Type your answer in the following <textarea> and submit a screenshot of the *entire* screen including the textarea.
(2) (Do this:) Create a web page containing JS code that does this: it displays a truth table with a missing truth value in one of its rows, and asks the user to type the missing value (which will always be either true or false, unless you are using some less common type of non-Boolean logic). It does this 10 times and the prints the user's final score. Hand in the web page and a screen shot of the entire screen showing your score playing it.
(Don't do this:)
Using JavaScript, write
code that will print 5 lines: one for each row of the truth table for OR, plus
a line containing the column labels.
Truth table
A B (A OR B)
-----------------------
T T T
T F T
F T T
F F F
Hint: You need to print out your truth table somehow. So, \n denotes the newline character (i.e. a line break) in JavaScript. On the other hand, <br> denotes a line break in HTML. Thus, if you put a \n in a string and write the string to the innerHTML of an HTML element like a <p>, it will display in HTML as white space (in other words, it will print as a space or a line wrap, as decided by HTML). Instead, put the substring "<br>" in the string and HTML will render the "<br>" as the desired line break. On the other hand if you print using pure JavaScript, for example using alert(), which creates a popup that contains text, not HTML, then \n in a string that you print using alert() will line break the string at that point. On the other hand, if you use alert() to print in its popup, if the string you print there contains the substring <br>, it will print out simply as the 4 characters "<br>". Confused yet?? It will become clearer when you try it, just like so many things in programming.
(3) Using JavaScript, write code that will print 5 lines: one for each row of the truth table for AND, plus a line containing the column labels.
(3) Explain, step by step, how to get the integer value of an 8-bit byte containing the following bit sequence: 00001111. Type your explanation in the textarea below and submit a full-screen screenshot showing the textarea. (Hint).
a. 00000001
b. 00000010
c. 00000011
d. 00000100
e. 00001000
f. 00001111
(5) (Optional in 2025, not required)
a. What is 7^7 in JavaScript? Explain. See https://www.w3schools.com/js/js_bitwise.asp for more information.
b. What is 7 & 7? Explain.
c. What is 7 | 7? Explain.
(4) Use the learning app at https://claude.ai/public/artifacts/af242f43-0243-4187-9d17-4b34b9295435. Provide a screen shot when you finish. Also give your assessment of the learning value of this app.
(5) Use the learning app at https://claude.ai/public/artifacts/a42c5fe1-e8c0-4db4-aa99-3e618ea45a93. Provide a screen shot when you finish. Also give your assessment of the learning value of this app.