From the course: Computer Science Principles Lab: JavaScript
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Create conditional tests - JavaScript Tutorial
From the course: Computer Science Principles Lab: JavaScript
Create conditional tests
- [Instructor] Conditional tests are ways for code to do different things based on evaluations that return a boolean value. Boolean values are either true or false, and they are a special variable type in JavaScript. To create a boolean variable, you simply need to create a new variable and set it equal to true or false. But note that you don't have to put quotation marks around the words, that would make it a string. Let's create a boolean variable now. Start with a var statement and then we'll add in the variable name, knowJavaScript, and we'll set it equal to true, without quotation marks. Create a console log message that will output the value and type of the variable. console.log("The variable knowJavaScript is equal to ") Then we'll concatenate the value of knowJavaScript, and then concatenate another string, "and is a " then we'll add in the string typeof knowJavaScript. Save the document and load it in the Chrome. The variable knowJavaScript is equal to true and is a boolean…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.