(English) JavaScript Full Course - Beginner To Pro - Part 1 (DownSub - Com)
(English) JavaScript Full Course - Beginner To Pro - Part 1 (DownSub - Com)
So this is an interactive
multi-page website we're we can
In part two,
what is JavaScript?
JavaScript is a technology
that we use to create websites.
A website is like
youtube.com or amazon.com.
browser.
Type in google.com at
the top and press enter.
work.
instructions.
simple.dev/j-basics
icon. Okay,
So this is an instruction to
create a pop-up with a text,
So this is an instruction
to create a pop-up again,
If we press enter,
programming languages.
enter,
the computer follows our instruction
or runs this code calculates two
math.
video description.
hello,
open, hello,
For now,
So in this lesson,
we learned that JavaScript is
basically giving instructions to a
in this lesson.
simple.dev/projects/amazon
JavaScript. First,
For example,
If we press enter,
If we press enter,
divide.
So forward slash is a
character for dividing.
If we press enter,
4.4.
number up here.
If we press enter,
and if we scroll to
the top of our project,
95 cents.
Next,
operators.
For example,
six.
done first.
order of operations,
JavaScript.
priority, so if we have
both in a calculation,
If we press enter,
bracket.
operations. First,
basketball,
If we press enter,
here.
So how do we do that?
100.
That's what percent means.
If we press enter,
the T-shirts,
Unfortunately,
We actually want to
calculate this number first.
20.95 plus
JavaScript.
0.1 plus
0.3,
but a little bit inaccurate.
So this problem is not
For example,
numbers,
we definitely want to
avoid any inaccuracies.
If we press enter
calculating with these floats
this problem?
instead of dollars.
So remember,
JavaScript.
If we do capital M,
enter,
In this situation,
enter,
brackets,
by dividing by 100.
If we
press enter,
page. So to summarize,
practice.
own.
If we press enter,
First,
and semicolon.
This code creates a popup on the
If we press enter,
In JavaScript. They
represent different things,
two is a number.
If we do type of quote,
If we press enter,
and as we learned, if we
add a string and a number,
JavaScript will automatically
convert this number into a string.
So how do we do this?
20.95 plus
7.99,
If we press enter.
unfortunately. Now we
have another problem.
inaccuracies,
Again,
close bracket,
to the string.
numbers. We break up
the string into parts,
All right,
If we press enter,
project inside.
For example,
press enter.
For example,
script
For example,
let's create a popup using alert
and
press enter.
special features.
Interpolation gives us a
much easier way to do this.
plus
seven 99 cents.
And we'll surround this in brackets
So interpolation is a
recommended solution. Next,
sum,
If we press enter,
So my personal recommendation is
to use single quotes by default.
unlike JavaScript,
Instead,
an HTML file.
greater than,
or command S on Mac.
new line.
paragraph of text.
To create an element, we
start with a less than symbol,
in html.
for example,
By the way,
code.
page. Instead,
the page.
And then inside these curly brackets,
of a style.
So that's the basic syntax of css.
space.
For example,
For example,
button.
and refresh.
For example,
specific elements.
click inspect.
So we already learned
about the console tab
the H T M L element
represents the entire webpage.
page.
In general,
server
To do that,
For example,
It gives us access to
more features of html,
To remove an indent,
two.
this file.
indents.
indents.
settings
this line,
wrapping. Finally,
hello
attribute.
double quotes.
Now if we save
So this is a comment,
if we save it,
later.
Now if we save,
slash here.
enter comment
For example,
this is a comment in
so this is a comment
element,
Again,
console.
variables,
variables.
Next,
by typing control A on
Windows or command A
on Mac.
variables.
element
now.
what is a variable? A
variable is like a container.
a new variable,
one,
To do that,
For example,
So instead of two,
calculation. So this
will be four plus two,
result
variable. Again,
For example,
If we save,
variable. Okay,
variable a name.
Lastly,
If we save,
is one instruction.
JavaScript. If we save,
semicolon insertion.
However,
Next,
For example,
so variable one.
three,
to something else.
then equals,
increasing it by one
and then saving it back.
super
simple.dev/projects/variables
products. So when we
click the plus two button,
in the console.
Next,
cart quantity
This.
value.
by typing let,
capital Q quantity.
on click attribute.
enter.
And now when we click this button,
the code.
So again,
Now if we save
so cart quantity,
And again,
try.
So if we scroll down,
In Camel case,
we capitalize quantity,
And finally,
Finally,
For example,
if we wrote
Console dot
and save
So if we change this to
type of message
and save,
string.
In this lesson, we
learned about variables,
In this lesson,
and If statements.
project.
bullions
type false.
So if we console dot
log this code console,
dot log
and save,
If we save,
and save,
for example,
triple equals,
log,
string 5.00.
If we save,
type.
So if we save, now,
true.
Hello.
If we save
else.
save
Because it is false,
So in here,
of code,
congrats.
brackets else.
if it is,
If we save,
So using Ls if branches,
Okay,
simple.dev/projects/bulls
dash scissors,
Next,
file.
Finally,
rock,
Paper, scissors.
So if we console dot
log this console dot log
paper or scissors.
Now let's convert these steps into
logical operators.
So first let's open the tab for
operator.
comparisons.
log rock,
thirds.
paper.
if random number
scissors.
For example,
dot log.
True or false.
So this is a logical or
operator IT checks if at least
For example,
let's create a new line
and type console dot
So if we save,
which is rock.
okay,
constant
attribute including
inside the if statement
called var.
So we generated a random
move for the computer,
is equal to rock.
a tie
it in the if statement.
this variable.
then we lose.
lose.
to scissors
an if statement.
computer move.
variable result.
anymore.
good.
if we click rock,
result. Here
Let's press okay and try paper.
statements.
and false,
truthy.
If we save
So how do we know if a
value is truthy or falsey?
For example,
curly brackets,
than zero,
as shortcuts.
For example,
into truth.
If we save, this will display truth.
learned yet.
at the bottom,
five.
For example,
at the bottom if we
create a variable with let
and we save,
question mark,
result equals
like zero,
value.
five.
u R or euros.
currency
undefined.
if we save.
paper, scissors.
click copy.
functions
If we save,
if we save,
This will run the code inside the function
project. First,
All right,
pick computer,
like this.
and paste.
variables. If we save
semicolon,
pick computer,
dot log
So.
function. So first,
So another solution is to
return this variable because
we can log it or we
can also save this in a
click scissors,
so don't worry,
if we can.
it works.
Let's press okay and click the paper
Okay,
of scope. Next,
display.
So let's do an example.
Let's say that we're working on the
final Amazon project and we need to
So function,
Let's name it,
However,
So instead of 1000,
calculate tax.
So this is an example of
a parameter. And lastly,
10% tax.
a 20% tax.
and save
undefined.
valid math.
0.1 If we save
code.
So this is a perfect
situation to use a parameter.
brackets. Next,
parameter,
To do that,
So as we learned,
So we'll type if
scissors,
scissors.
correctly.
down here.
play game.
button.
if player move is
So I picked rock,
Let's press.
Okay.
So by using a function with a parameter,
works.
So inside a function we
can call other functions.
and save.
code.
functions.
file,
dot html.
and in here,
Finally,
bracket,
For example,
So if we save,
property price.
log,
an object.
property to cotton
socks. So at the bottom,
if we type console dot,
and save.
object,
else.
product.new property
and save
delete,
property.
value.
object.
values at once.
So objects,
simple.dev/projects/objects
and press enter.
code.
wins.
If it is a win,
So down here,
object by one.
brackets.
lose.
multi-line strings.
So after this,
zero.
equal to zero.
to another object
Inside.
two.name.
property In JavaScript
we have another way of
brackets.
trying to do math.
Now if we save
day if we save,
dot notation.
a calculation or anything
that results in a value.
bracket notation.
easier to read.
like stars,
colon 4.5,
So this is called a
nested object or an object
inside an object.
product.
dot rating.
object.
JavaScript.
brackets if we save,
Console is an object
provided by JavaScript and
object.
and save,
this will show us that
console dot log is a function.
Another example of a
method is math dot random,
syntax?
So stringy is a method
of the adjacent object,
product two.
result
And save.
If we scroll up,
JavaScript object.
jason.pars and
brackets.
So we actually have a
Jason string up here.
and save
and Jason.
zero. However,
string is a name.
So we need to convert
our object into a string.
stringy.
stringy
string.
so we need to convert
this back to an object.
We also learned how to do
this earlier using jason.pars.
So at the front
So we need to convert it
back into an object using
jason.pars.
to remove.
So we're going to remove the score.
So we'll type the string score if we
If we save,
is equal to null,
not score.
operator, which is
exactly what we need here.
and type
For example,
Okay,
methods,
can see,
first,
and bulls.
So there's no way to
actually see this reference,
computer's memory.
For example,
to object one.
object here,
and save.
the object.
So at the bottom,
object one.
For example,
If we save,
object.
to object one,
So if we save,
objects.
four.
object.
message.
called message.
object four.
7 99.
price.
price
is whatever is inside
the message variable,
before.
log method.
dot method.
brackets.
If we save,
and save,
and references,
shorthand properties
and shorthand methods.
dom.
html.
And in here,
click inspect
And then click the console.
So here,
dom.
document object.
document.
If we save,
It will remove the button and just
put hello.
And now that we learned objects in the
notation.
if we save
or the dom.
It contains properties
like body and title that we
the webpage.
to properties,
star,
title.
dot log
and save,
changed
and save.
Now the title at the top of the
body.
If I expand this,
We can have H T M L
elements inside JavaScript.
webpage.
So for example,
capital H T M L.
dot log
and save
inner capital T M L,
H T M L.
greater than.
So this is HTML code for creating a
Good job.
If we save,
All right,
As a reminder,
query selector.
capital S,
dot log,
If we type body,
and save.
html,
need. Next,
and save.
js dash button.
dot,
element name.
button.
and save.
And now you will see that
this code gives us the second
inquiry selector,
class. In fact,
And remember,
capital E element.
lm.
To make it clear there's an H T
M L element inside this variable.
simple.dev/projects/dom
So using css,
YouTube.
enter.
And in here,
projects
Finally,
paragraph first,
subscribe button.
attribute.
double quotes.
class js dash
on the page.
to this result.
subscribe.
Now if it is equal to
subscribe inside the curly
brackets,
sub described.
text.
So before we move on
to the second project,
of in a pop-up.
game,
press enter.
quotes
JS dash score.
query, selector
js dash score.
So JS dash score.
inner capital H T M L,
If we scroll down,
read.
paste.
something?
So the paragraph element here is known as
a block element.
description. Alright,
If we play it doesn't
update it on the page,
and brackets.
page. So first,
dash result
greater than,
js dash moves.
Now let's use the
dom to put the result and the
moves in these paragraphs.
which is here.
So we display it in a popup
and instead of a popup,
dash result
T M L.
dash moves,
P,
is below $40,
we did before.
curly brackets.
And inside on click we're just
going to call the function.
So calculate total
brackets.
So first,
input
Element and make it equal
to this element and
remove the extra bracket.
value.
and save.
So down here,
box.
2,510.
and save.
and aha,
25 and 10 here.
To do that,
converts it into a
number. So now if we save
So remember whenever we
get a value from the dom,
press enter.
attribute on click,
Key Down,
typing.
message.
listeners.
object. If we save
save.
page.
Lastly,
and brackets.
parameter.
we're going to go up to
these brackets and type
event.
25 enter.
So this still works.
JavaScript.
and brackets.
minus five.
multiply or divide,
20.
and save.
into 2 55.
lesson.
console,
course.
and save.
And this will do the same thing as
automatically add
window.at the front for us.
for us automatically,
inside an element.
We worked on three projects using the dom.
key down.
dom.
website.
simple.dev/projects/dom-with-css
nice.
our files.
rename.
enter.
element.
So inside the head section
we're going to create an element
appearance.
currently,
As a reminder, this is
just a review of css.
If you want to learn CSS in more detail,
description.
So we just added one style to this
button.
padding.
10 PX and save.
A pixel is a unit of
measurement in computers.
example,
Let's save.
So we'll save.
And now the spacing looks close
text,
radius.
Let's save.
project.
colon pointer,
which is here.
colon gray,
click inspect,
remove.
selector,
family colon,
So if we need to, we
can override it later.
On the outside of an
element is called margin.
and save.
of 30 pixels.
css. Again,
So first,
colon,
of 10 pixels, padding,
right of 10 pixels.
direction if we save.
dash button.
colon, green,
and semicolon and save.
spaces,
which is 50 pixels.
So instead of 50 pixels,
let's bring it down to 15 pixels and
colon pointer,
$35. Finally,
So I'll rearrange my
windows so we can see this
files.
scissors.
press enter.
side by side.
colon,
Click inspect
and colon,
colon, aerial,
All right,
dash size,
In our css,
we'll use font dash weight
So for me,
and save.
its shape.
which is images,
If we save
m G, greater than,
dash emoji p n g.
of the page.
colon,
radius, colon.
buttons.
And again,
computer.
emoji png.
JavaScript to insert
these results instead.
To do that,
and save.
paths.
For example,
this icon.
own file.
with css.
code
R E L means relation.
If we save,
CSS files.
video description.
So in this lesson we
reviewed CSS and added CSS
files.
enter.
And in here,
and loops.
10,
and save,
which is 20.
If we save,
it displays 20.
brackets.
For example,
in this array,
comma two.
array.is array
my array length.
push 100,
my array dot
remove.
If we give it one,
If we give it two,
So for now,
simple.dev/projects/erase
dinner,
files.
JavaScript code.
enter.
equals.
js and save.
element to start.
list. Next,
do name. Finally,
Next,
query selector
to this result.
value,
if this is working.
in the console.
So that's how we create this first
if we save.
add,
page? To do this,
loops. So first,
one.
For example,
five.
five.
this variable.
plus one.
save.
it works.
So this is true,
at five.
brackets.
plus.
So this will increase the value of I by
So in JavaScript, there's
actually two types of loops.
I and save.
loop.
So what's an example
of a non-standard loop?
0.5.
0.5.
random.
dinner,
another string wash dishes,
console. To do that,
and so on.
zero.
minus one
minus one.
For now,
So for now,
index.
if we save,
array.
list length.
means index.
So first,
So down here,
learned earlier,
So at the bottom,
So if the array is 1, 1 3,
accumulator pattern.
result.
this array.
list html.
we want to display it
on the page. To do that,
and paste.
So this will give us some default
semicolon,
cons to do,
template string.
paragraph,
capital H T M L,
list capital H T M L
do list H,
html.
So in this situation,
below,
And to do that,
equals js dash to do
JavaScript.
string.
dash list.
JavaScript.
inner capital H T M L,
an indent.
using JavaScript.
Let's take a break before continuing
with the rest of this lesson,
far.
So in this version we
can type A to-do like
on the page.
to read.
Now if we save,
you can see that in the
generated html when we
Next,
type.
array of strings,
property,
dash 22,
and do date
name equals to do
do date equals to do
if we save.
Before we continue,
destructuring.
curly brackets,
name equals to do
this out
Next,
dot value.
date property.
bracket.
want to load.
So we created this in the styles folder,
So in here,
to dash grid.
dash,
into a grid,
grid.
So let's save.
To do this,
If we save,
column.
third column.
Next,
HTML file.
save.
dash gap,
style.to do dash
Let's save.
So again,
dash input.
Let's save.
color colon,
colon.
15 pixels save.
and save.
However,
star slash
1, 2, 3.
array is in memory.
push
Four,
and save,
slice instead,
If we save,
the array. 1, 2, 3.
value.
and save.
is equal to eight.
If it is equal to eight,
semicolon, if we save
I is equal to three.
If we save,
For example,
So to check if a number
is divisible by three,
we have to do this
increment step manually.
If we save,
six,
and nine.
So remember in a wild loop if we
use continue,
All right,
So cons,
So let's create a
function around this loop.
curly bracket.
and save.
doubled.
files.
And in here,
So this is a function
and it lets us reuse code
which is greeting,
display. Hello.
numb.
this function.
in a variable.
function
So object one.fun.
save,
Hello three.
function,
run brackets.
curly brackets,
If we save,
function.
or a callback. So to summarize,
time out.
brackets.
a second parameter.
and save.
code. In addition,
code.
Asynchronous code is
the exact same concept.
set interval.
capital I interval
number in milliseconds.
If we save
And here,
press enter.
rename.
remove copy,
it side by side.
click attribute.
file.
So we'll run a function called
game function.
1000.
So this means it will run this function
brackets.
playing,
so not is auto
playing.
playing.
d constant interval
scroll up.
undefined to start.
interval.
interval id.
And then at the bottom let's
also change is autoplaying
So is auto playing
slash star.
value.
console. So let's go
through this step by step.
like this.
And four each also has another feature.
comma.
All right,
now let's do a practical example
using the for each method
page.
remove copy,
comments.
file.
continue.
If we save,
cost
If we save,
Hello.
five.
For example,
Two,
curly brackets
plus three.
So when an arrow function
only has one line like this,
So let's scroll up in
this code to the for each
file.
autoplay function.
curly brackets.
this,
Next,
object.
feature.
button.
double quotes.
js dash button.
event listener.
Add Event Listener lets us run some code
So at the bottom,
this element.
attribute. However,
event.
capital L,
So above this,
event listener.
event listener.
click attribute.
which is up here.
listener brackets.
For example,
string rock.
which is undefined.
and rock.
listener.
button.
dash button.
as exercises.
key down.
brackets,
but it provides it as a
parameter to this function.
save.
brackets,
curly brackets.
And inside here we check if
string S. If it is,
If we type P,
project.
html.
Okay,
which is here.
button.
all.
like,
So at the end,
as usual,
So index.
button dot,
brackets.
and brackets.
and save
or equal to zero.
else
copy.
zero.
1, 1 3,
and save,
it will create an array
where each value becomes 10.
in the return.
and save,
and save.
And this will give us
2, 2 6.
called a closure.
to-do list js
which is here.
the console,
called a closure. If a
function has access to a value,
We learned an array
method called for each,
interested in learning
JavaScript. Thanks again,
and I'll see you in the next one.