Open Dnyandeo33 opened 2 years ago
Week 1
const
console.assert
instead of console.log
Documenting Functions - Understanding-wise okay but writing-wise not okay.
It's not easy to read, understand and explain what a function does. This will take time to master which is why we introduce it early
@colevandersWands Thank you so much, Your comment always inspire me. ,βΊοΈβΊοΈ
@Dnyandeo33 and while documentation makes life easier in many projects, it is also ok not to use it in some cases :)
- How to use
console.assert
instead ofconsole.log
and these two have different purposes
Week 2
.push
, .pop
, .unshift
, .shift
, .indexOf
, .splice
- Logically I'm not strong. Many times I stuck with logic.
well that's ok, and that is why we are here, to learn and practice and practice some more :)
Week 3
Everything went well but I'm struggling with these test errors.
FAIL src/utils/average.spec.js
β average: calculates the average of an array of numbers βΊ averaging numbers βΊ returns 0 for an empty array
expect(received).toEqual(expected) // deep equality
Expected: 0
Received: NaN
5 | it('returns 0 for an empty array', () => {
6 | const actual = average([]);
> 7 | expect(actual).toEqual(0);
| ^
8 | });
[9](https://github.com/lab-brussels-1/Group-2-numbers-project/runs/6918331357?check_suite_focus=true#step:5:10) | it('can average a single number', () => {
[10](https://github.com/lab-brussels-1/Group-2-numbers-project/runs/6918331357?check_suite_focus=true#step:5:11) | const actual = average([4]);
at Object.<anonymous> (src/utils/average.spec.js:7:[22](https://github.com/lab-brussels-1/Group-2-numbers-project/runs/6918331357?check_suite_focus=true#step:5:23))```
## Sunday Prep Work
- Continue practicing
Everything went well but I'm struggling with these test errors.
do you have a link to the repo/branch/file? I will investigate
try this
export const average = (nums = []) => {
let averageNum = 0;
for (const num of nums) {
averageNum += num / nums.length;
}
return averageNum;
};
@danielhalasz Thank you so much It's work.
Inside JS
Learning Objectives
Priorities: π₯, π£, π₯, π (click to learn more)
There is a lot to learn in this repository. If you can't master all the material at once, that's expected! Anything you don't master now will always be waiting for you to review when you need it. These 4 emoji's will help you prioritize your study time and to measure your progress: - π₯: Understanding this material is required, it covers the base skills you'll need to move on. You do not need to finish all of them but should feel comfortable that you could with enough time. - π£: You have started all of these exercises and feel you could complete them all if you just had more time. It may not be easy for you but with effort you can make it through. - π₯: You have studied the examples and started some exercises if you had time. You should have a big-picture understanding of these concepts/skills, but may not be confident completing the exercises. - π: These concepts or skills are not necessary but are related to this module. If you are finished with π₯, π£ and π₯ you can use the π exercises to push yourself without getting distracted from the module's main objectives. ---
0. Asserting
let
vs.const
: You can explain the differences betweenlet
andconst
including: uninitialized declarations and reassignment. You can determine when a variable can be assigned withconst
in a program.===
and!==
operators compare strings, and can predict the result of any string comparison.console.log
: You can useconsole.log
to create program traces in the console, and to print other helpful info for developers.console.assert
: You can use theconsole.assert
for assertion testing, and can write a helpful message assertion message.1. Primitives and Operators
typeof
: You can predict thetypeof
operator's output for values from any of the 5 main primitive types.Boolean()
,String()
andNumber()
to convert between primitive types.&&
,||
,!
and? :
.&&
and||
.+
,!
and>
.2. Control Flow
if
/else
statements.while
loops.for-of
Strings: You can predict and trace simple programs that iterate through the characters of a string usingfor-of
.for
loops works by refactoring simplefor
loops intowhile
loops.break
.continue
.3. Functions
5. Unit Testing
describe
/it
/expect.toEqual
functions are defined by a testing library and made available as global variables in a testing environment. They are not part of JavaScript!file.__.js
. Sub-extensions are a convention for developers and development tools. They do not change how JavaScript inside the file works.6. ES Modules
?deps
lens to visualize the dependencies in a folder.'use strict'
!export const _ = () => {};
import { _ } from './path/to/file.js';
6. Using Functions
7. Arrays
const arr = ['items'];
.at()
and a positive or negative index.arr[4] = 'hello'
.Array.isArray(something)
const shallowCopy = [...arr];
8. Functional Array Methods
[].every
[].some
[].map
[].filter
[].find
[].reduce
9. Objects
const obj = { a: 1, b: 2 };
.