Skip to content

Commit

Permalink
fix: content change in Javascript Planet-NULLCAST#317
Browse files Browse the repository at this point in the history
Javascript content changed in chapter 6, 7 and 8
  • Loading branch information
reshmarajank committed Nov 2, 2021
1 parent d472417 commit 4a7464a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions courses/javascript/datatypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ testCase: [
]
---

A value in JavaScript is always of a certain type. It can be a string or a number or of any other type.
A value in JavaScript is always of a certain type. It can be a `string` or a `number` or of any other type.

There are **eight basic data types** in JavaScript. A varaible can store any such value. It can store a string at one moment and then store a number later.

Expand All @@ -39,7 +39,7 @@ Programming languages that allow such things, such as JavaScript, are called **

## Number

The _number_ type represents both integer and floating point numbers.
The _`number`_ type represents both integer and floating point numbers.

```javascript
let n = 123;
Expand All @@ -48,7 +48,7 @@ n = 12.345;

## String

The _string_ in JavaScript must be surrounded by quotes. In JavaScript, there are 3 types of quotes. Double quotes "" , Single quotes '' and Backticks ``. Double and single quotes are “simple” quotes. There’s practically no difference between them in JavaScript. Backticks are “extended functionality” quotes. They allow us to embed variables and expressions into a string by wrapping them in ${…}, for example:
The _`string`_ in JavaScript must be surrounded by quotes. In JavaScript, there are 3 types of quotes. Double quotes "" , Single quotes '' and Backticks \`\`\. Double and single quotes are “simple” quotes. There’s practically no difference between them in JavaScript. Backticks are “extended functionality” quotes. They allow us to embed variables and expressions into a string by wrapping them in `${…}` , for example:

```javascript
let str = "Hello"; // Hello
Expand All @@ -59,7 +59,7 @@ let result = `the result is ${1 + 2}`; // the result is 3

## Boolean

The boolean type has only two values: true and false. This type is commonly used to store yes/no values: true means “yes, correct”, and false means “no, incorrect”.
The boolean type has only two values: `true` and `false`. This type is commonly used to store yes/no values: `true` means “yes, correct”, and `false` means “no, incorrect”.

```javascript
let nameFieldChecked = true; // yes, name field is checked
Expand All @@ -70,8 +70,8 @@ let ageFieldChecked = false; // no, age field is not checked

## Complete the tasks below:

- Create a variable num of type let and value 101
- Create a variable `num` of type `let` and value 101

- Create variable str of type let and value "hello"
- Create variable `str` of type `let` and value "hello"

- Create a variable flag of type let and value true
- Create a variable `flag` of type `let` and value `true`
24 changes: 12 additions & 12 deletions courses/javascript/logical-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ testCase: [
]
---

There are four logical operators in JavaScript: || (OR), && (AND), ! (NOT), ?? (Nullish Coalescing).
There are four logical operators in JavaScript: `||` (OR), `&&` (AND), `!` (NOT), `??` (Nullish Coalescing).
Although they are called “logical”, they can be applied to values of any type, not only boolean. Their result can also be of any type.

## OR ||

The “OR” operator is represented with two vertical line symbols || :
The “OR” operator is represented with two vertical line symbols `||` :

```javascript
result = a || b;
```

In classical programming, the logical OR is meant to manipulate boolean values only. If any of its arguments are true, it returns true, otherwise it returns false.
In classical programming, the logical OR is meant to manipulate boolean values only. If any of its arguments are `true`, it returns `true`, otherwise it returns `false`.
There are four possible logical combinations:

```javascript
Expand All @@ -53,17 +53,17 @@ console.log(true || false); // true
console.log(false || false); // false
```

As we can see, the result is always true except for the case when both operands are false.
As we can see, the result is always `true` except for the case when both operands are `false`.

## AND &&

The AND operator is represented with two ampersands &&:
The AND operator is represented with two ampersands `&&`:

```javascript
result = a && b;
```

In classical programming, AND returns true if both operands are truthy and false otherwise:
In classical programming, AND returns `true` if both operands are truthy and `false` otherwise:

```javascript
console.log(true && true); // true
Expand All @@ -85,15 +85,15 @@ if (hour == 12 && minute == 30) {

## ! NOT

The boolean NOT operator is represented with an exclamation sign !.
The boolean NOT operator is represented with an exclamation sign `!`.

```javascript
result = !value;
```

The operator accepts a single argument and does the following:

- Converts the operand to boolean type: true/false.
- Converts the operand to boolean type: `true`/`false`.
- Returns the inverse value.

### Example:
Expand All @@ -107,10 +107,10 @@ console.log(!0); // true

## Complete the tasks below:

- Create two variables a and b and assign values true and false respectively.
- Create two variables `a` and `b` and assign values `true` and `false` respectively.

- Perform an AND operation on a and b and assign the value to a variable result.
- Perform an AND operation on `a`and `b` and assign the value to a variable `result`.

- Perform an OR operation on a and b and assign the value to result.
- Perform an OR operation on `a` and `b` and assign the value to `result`.

- Perform a NOT operation on a and assign the value to result.
- Perform a NOT operation on `a` and assign the value to `result`.
18 changes: 9 additions & 9 deletions courses/javascript/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ To create a variable in JavaScript, we can use `var`, `let` and `const`.

It's easy to get confused about the difference between `var`, `let` and `const`. No worries fellow developers, we got your back.

It is important we understand the difference betweeen various scopes in `js`.
It is important we understand the difference betweeen various scopes in js.

## Scopes

Expand Down Expand Up @@ -133,7 +133,7 @@ function letTest() {
const varname1 = "some value";
```

Variables declared using `const` is just like let. The only difference is that constants cannot be re-assigned.
Variables declared using `const` is just like `let`. The only difference is that constants cannot be re-assigned.

`const` cannot be redeclared in the same block too. But can be redeclared inside sub-blocks.

Expand All @@ -154,16 +154,16 @@ console.log(a); // 'something'

## Complete the tasks below:

- Create a variable named a using const and initialize it with a value of 9
- Create a variable named `a`, using `const` and initialize it with a value of 9

- Create b variable using let with variable name a.
- Create a variable using `let`, with variable name `b`.

- Assign the variable b a value of 5.
- Assign the variable `b`, a value of 5.

- Then change the value of b to "Message".
- Then change the value of `b` to "Message".

- Create c variable using let with variable name a.
- Create a variable using `let` with variable name `c`.

- Assign the variable c a value of 7.
- Assign the variable `c`, a value of 7.

- Then change the value of c to "Something".
- Then change the value of `c` to "Something".

0 comments on commit 4a7464a

Please sign in to comment.