Greetings! Today, we're about to start an exciting journey into the world of JavaScript. We'll focus on JavaScript fundamentals - printing, comments, data types, and expressions. Imagine you can make a website play a game with its visitors or react to their actions like a fellow human. That's what JavaScript does! Ready to dive in? Let's start.
JavaScript brings static web pages to life by making them interactive! Every language has syntax — rules about how sentences (or in our case, statements
) should be written. JavaScript is no exception. Let's have a quick look:
In the above example, we're giving a shoutout to the world: "Hello, World!"
. Remember to always end each statement with a semi-colon (;
).
A great start, isn't it? Let's keep going.
Coding isn’t just for computers. You also leave notes for fellow humans — future developers or even your future self — known as 'comments'. A comment can either be a one-liner that uses //
, or a note stretching across multiple lines within /*
and */
. These comments explain your code’s purpose, design, and functioning, making reading code much easier.
An essential thing to note is that, unlike JavaScript statements, comments do not need to end with a semi-colon (;
). This is because they're not executable code and are ignored by the JavaScript engine.
JavaScript processes three primary data types: Numbers, Strings, and Booleans. Try entering the following commands and observe the results:
Let's move on to expressions, which are pieces of code that produce a value. It can be numbers, strings, or boolean values. For instance, 2 + 2
yields 4
, and "Hello, " + "World!"
results in "Hello, World!". Experiment with basic arithmetic operations, like addition (+
), subtraction (-
), multiplication (*
), division (/
), and modulo (%
, the remainder from division) in the CodeSignal IDE.
Take a look at this combination of comments, print commands, and expressions:
Comparison operators include <
(less than), >
(greater than), <=
(less than or equal to), >=
(greater than or equal to). They are used to compare two values and return boolean true or false.
Fantastic! You've taken some confident strides into the JavaScript world. We've touched upon JavaScript printing, comments, data types, and expressions. Now, you're all set to roll up your sleeves and put your newfound knowledge to practice! So, let's move onto the practice tasks and flex those JavaScript muscles!
