Skip to content

Commit

Permalink
[ CURRICULUM ][ WEEK 7 ][ WiP ]
Browse files Browse the repository at this point in the history
  • Loading branch information
kostasx committed Nov 16, 2023
1 parent 52fd4ab commit 37ac268
Show file tree
Hide file tree
Showing 540 changed files with 19,948 additions and 904 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Errors

Errors are unavoidable in programming. In Welcome to JS most of the exercises
ask you to study programs that work so you shouldn't face tooo many errors. When
you do get an error, don't let this get you down. It's easier to write code that
_has_ errors than to write code that _doesn't_!

Understanding and fixing errors in your code will take lots of practice, in the
next module you will study errors in depth. For now all you need to know about
errors is:

- the error _name_ and _message_ so you can search about it online. You don't
need to understand everything you read about the error, but you should be able
to find links about it.
- finding the line where the error occurred by reading the error log and
clicking on the line number .
- `ctr-z`, so you can undo your error and try again.

As you complete each exercise you should keep track of all the errors you
encountered. Try thinking of errors as the computer's best attempt at helping
you fix your mistakes. Take notes on which errors you make the most often and
what you figure out to avoid them.

## Run Early and Often

Another strategy for dealing with errors is to run your code early and often:
after every single tiny change try running the program. This helps you figure
out what went wrong because the error must be related to the tiny change you
just made.

## ReferenceError: \_ is not defined

There is one error you do not need to keep track of in your notes -
`ReferenceError: _ is not defined`. You will get this error all the time, and
it's not because of the code you write. we use \_ to show you where something is
missing in the program, but JavaScript reads \_ as a variable that has not been
declared.

Instead of dreading this error, you can thank it for telling you where the next
blank is!

---

- Launchcode:
[categories](https://education.launchcode.org/intro-to-professional-web-dev/chapters/errors-and-debugging/categories-of-errors.html),
[diagnosing](https://education.launchcode.org/intro-to-professional-web-dev/chapters/errors-and-debugging/diagnosing-error-messages.html)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Comments and Logs

Comments and logs are for developers, not for the computer. They exist to help
you understand your program.

Comments and logging will not change what your program does, just how easy it is
to understand.

---

## 🥚 Comments

```js
'use strict';
// comments are for people to read, not computers
// these are both one-line comments

// if you run or trace this snippet, nothing will happen
```

```js
'use strict';
/* this is a block comment
block comments are useful for writing longer messages
- and for
- things like
- lists
if you run or trace this snippet nothing will happen
*/
```

---

## 🥚 Logging

```js
'use strict';
// print a message to the browser's console
console.log('-- logging --');

// an empty log
console.log();

// you can log more than one thing at a time
console.log('a', 'message', 'from', 'beyond'); // 'a', 'message', 'from', 'beyond'
```

---

## References

- Comments
- [launchcode](https://education.launchcode.org/intro-to-professional-web-dev/chapters/how-to-write-code/comments.html)
- [programiz](https://www.programiz.com/javascript/comments)
- [javascript.info](https://javascript.info/structure#code-comments)
- [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#comments)
- Logging
- [launchcode](https://education.launchcode.org/intro-to-professional-web-dev/chapters/how-to-write-code/output.html?highlight=log)
- [programiz](https://www.programiz.com/javascript/console)
- [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Console/log)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 🥚 Primitive Values

Programming computers is all about processing _data_. Data comes into a program,
your program processes the data, and some new data comes out at the end. In
JavaScript the most basic kinds of data are **primitive values**. When talking
about a primitive value, there are two important pieces of information:

- **Type**: What type of data is it? a string? a number? a boolean? undefined?
- **Value**: Which one of it's type is it? Is it the _number_ **5**? or the
_string_ **'5'**?

You will learn more about each of these types as you work your way through Just
Enough JavaScript:

```js
'use strict';
console.log('--- booleans: true and false ---');
console.log(true);
console.log(false);
```

```js
'use strict';
console.log('--- strings: anything wrapped in quotation marks ---');
console.log('hello');
console.log('good bye');
console.log('12'); // <- this actually a string!
console.log(''); // an empty string
```

```js
'use strict';
console.log('--- undefined: one way to say "there is nothing here" ---');
console.log(undefined);
```

```js
'use strict';
console.log('--- null: another way to say "there is nothing here" ---');
console.log(null);
// we will later cover the difference between null and undefined
```

```js
'use strict';
console.log('--- numbers: numbers that are not wrapped in quotation marks ---');
console.log(12);
console.log(3.14);
console.log(0);
console.log(-12);
console.log(10_000_000_000);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Marking Syntax

The marking exercises in this chapter will have 3 syntax features you need to
study:

1. **Primitives**: A small arrow _under_ the primitive.
1. **Identifiers**: A line _under_ the identifier.
1. **Function Calls**: A line under the identifier and a half-box under the
arguments.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// #todo

// prettier-ignore
{ // so prettier does not remove the extra spacing

'use strict';


console.log('hello');


console.log(true);


console.log();


console.log('are you hungry?', false);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"--defaults": {
".js": "highlight"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Marking Syntax

The marking exercises in this chapter will have 4 syntax features you need to
study:

1. **Primitives**: A small arrow _under_ the primitive.
1. **Identifiers**: A line _under_ the identifier.
1. **Function Calls**: A line under the identifier and a half-box under the
arguments.
1. **Operators**: A small arrow _above_ on the operator.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// #todo

// prettier-ignore
{ // so prettier does not remove the extra spacing

'use strict';


2 + 2;


true === true;


2 === '2';


console.log('hel' + 'o!');


console.log(2 === 2);


console.log(true === false);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"--defaults": {
".js": "highlight"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// #todo

'use strict';

// your answers should only include numbers and +

console.log('--- find 5 ways to log the number 5 ---');
// examples
console.log(5);
console.log(0 + 2 + 3);
// exercises
console.log();
console.log();
console.log();
console.log();
console.log();

console.log('--- find 4 ways to log the number 4 ---');
// examples
console.log(4);
console.log(2 + 2);
// exercises
console.log();
console.log();
console.log();
console.log();
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// #todo

'use strict';

// your answers should only include strings and +

console.log('--- find 3 ways to log "hello" ---');
// examples
console.log('hello');
console.log('h' + 'ello');
// exercises
console.log();
console.log();
console.log();

console.log('--- find 4 ways to log "good bye" ---');
// examples
console.log('good bye');
console.log('good' + ' ' + 'bye');
// exercises
console.log();
console.log();
console.log();
console.log();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// #todo

'use strict';

// your answers must include ===, but can use any type

console.log('--- write 5 comparisons that evaluate to true ---');
// examples
console.log('hello' === 'hello');
console.log('Bye' === 'Bye');
console.log(1 === 1.0);
// exercises
console.log();
console.log();
console.log();
console.log();
console.log();

console.log('--- write 5 comparisons that evaluate to false ---');
// examples
console.log('hello' === 'hello ');
console.log('Bye' === 'bye');
console.log(1 === 1.1);
// exercises
console.log();
console.log();
console.log();
console.log();
console.log();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"study": {
"trace": false,
"ask": false,
"loopGuard": false,
"parsons": false,
"flowchart": false,
"variables": false,
"table": false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// #todo

'use strict';

// your answers must use typeof, but can use any values
console.log('-- write 2 values with the type "boolean" --');
console.log(typeof _); // 'boolean'
console.log(typeof _); // 'boolean'

console.log('-- write 1 value with the type "object" --');
console.log(typeof _); // 'object'

console.log('-- write 5 values with the type "string" --');
// examples
console.log(typeof 'hello'); // 'string'
console.log(typeof ''); // 'string'
// exercises
console.log(typeof _); // 'string'
console.log(typeof _); // 'string'
console.log(typeof _); // 'string'
console.log(typeof _); // 'string'
console.log(typeof _); // 'string'

console.log('-- write 5 values with the type "number" --');
// examples
console.log(typeof 0); // 'number'
console.log(typeof 18.5); // 'number'
// exercises
console.log(typeof _); // 'number'
console.log(typeof _); // 'number'
console.log(typeof _); // 'number'
console.log(typeof _); // 'number'
console.log(typeof _); // 'number'
Loading

0 comments on commit 37ac268

Please sign in to comment.