Okay so let's work on the story. So first we have to 1
create a fire spell array and a frost spell array containing 2
respectively firebolt firewall and frostbolt and blizzard. So 3
I think we already created these. We just have to add 4
other ones. So fire spell we have the firebolt and we just 5
screw in to create another one. Firewall. And here we're just 6
going to add a frostbolt. 7
So here we are good create a fire wizard and initialize it 8
with the fire spell array sure no problem so we have a wizard 9
and we're going to initialize it with a fire spell Okay. Okay 10
create a frost wizard so let's do the same thing with the 11
frost wizard and I'm going to call this one fire wizard and 12
this one will be initialized with the frost 13
bells going to remove that 14
just all the fire wizard spell at once. So fire wizard. just 15
all at once. 16
Cast a big bang from the fire wizard spell book and if you 17
throw the error catch it so indeed there is no big bang in 18
this spell book okay in the Fire Wizard spell book so 19
technically it should crash so let's make sure first that it's 20
crashing fire wizard that cast from spell book and then fire 21
spell name. Big Bang so let's see It seems that it is 22
crushing indeed. You don't have this spell in your spell book 23
so we just have to catch this error this way the application 24
doesn't crash so means that it's working so we're going to 25
surround this by a try/catch 26
try catch here we have the error that is of type unknown 27
for now and we're going to console.log error and we're 28
going to cast that as an error 29
And this way we know that there is a message inside. And I'm 30
going to write error before. And technically error you don't 31
have the spell in your spell look so it's working fine cool 32
Now cast all the frost wizard spell at once. So this one is 33
easy. Frost wizard. cast all at once. Okay, everything seems to 34
work fine. And finally cast a blizzard spell from the frost 35
wizard spell book so this one should work because we have the 36
blizzard in the spell book so frost wizard.cast from spell 37
book 38
frost spell name.blizzard and Blizzard. Yep. It's 39
working. Okay so we are good with the story. Great. Uh okay 40
cool so good job doing this exercise. Uh now in the next 41
video I'm just going to show you how to specifically type or 42
is it again? Yep. This. Okay? Like I told you we can send 43
anything and we want to restrict that to either fire 44
spell names or frost spell names depending on the type of 45
the wizard. So in the we're going to see that we can 46
actually create types conditionally. So let's do that 47
in the next one.