Skip to content
Advertisement

Tag: switch-statement

Iterating through a an array executing a switch statement returns TypeError: Cannot assign to read only property ‘location’ of object ‘#’

I have a read only array that i copied to become a mutable array let mutableForecast = […forecast] I am taking that new array and iterating through it with forEach so i can mutate the array. im trying to use some flow control with a switch statement, but I am getting TypeError: Cannot assign to read only property ‘location’ of

Switch…case in JS

This simple problem gives me an error. Does not get the correct answer. I will be glad if you help. Output: You did not pass Answer this way can you explain why we write true? – Hussein Nadjafli (PO) The JS switch only works on strict equality. is equivalent to in your code you replace the possible values [’x1’,’x2’,…] with

javascript fizzbuzz switch statement

I’m currently taking the code academy course on Javascript and I’m stuck on the FizzBuzz task. I need to count from 1-20 and if the number is divisible by 3 print fizz, by 5 print buzz, by both print fizzbuzz, else just print the number. I was able to do it with if/ else if statements, but I wanted to

Advertisement