Today, I finished studying with variable, operator, list, and dictionary.
For variable, it's like a box with a number or any type of code inside.
Ex.
let a = 10 -> I'm putting 10 inside to 'a'
Then I don't have to write 10 every time I need but I can use variable 'a' like console.log (a)
or I can use it with operator
console.log(a+10)
**
%
/
+
whatever
as well as the list and dictionary
It will be very boring if I have to write all the variables one by one right?
let a = 1
let b = 2
let c = 3......
but I can put them all inside the same box by list code
let a_list = [1, 2, 3, 4....] -> seems '_' means putting some specific type of code
since I made variable 'a' as a list type, I can get the number I want
x_list = [add info]
console.log(a_list[1]) -> means taking the 1th item from a_list->remember in coding, it always starts from 0
Then it will get '2'
If I want to add something to a list code,
x(name of the variable)_list.push('info to add')
Then the info I want to add will be added to the list
For the dictionary, it's like
x_dict = {add info} but add info like-> {'key' : 'value}
key -> name of value
value -> info that will be shown on to screen
If I use the key, it will show the value.(not the key)
The list and dictionary work similarly, so I was not that hard to understand
So I made a funny thing today
Here is the boss! choose the weapon
list.html:53 (3) ['wood stick', 'wooden sword', 'wooden shield']
list.html:54 (3) ['stone', 'stone sword', 'stone shield']
list.html:55 (3) ['metal stick', 'steel sword', 'metal shield']
list.html:60 You have chosen the weapon: stone sword, Damage : 4
hehe..