Skip to content
Advertisement

Tag: arrays

How to find first non null value in a typescript array?

I have an arr variable which looks as below: I want to print out the first non-null value from within the arr array variable. In above array, the output should be hello I have written following logic but it is not giving the correct result: Answer Just use find: It returns the value of the first element in the provided

Decode the Morse code, advanced JS (codewars)

Here is a task: When transmitting the Morse code, the international standard specifies that: “Dot” – is 1 time unit long. “Dash” – is 3 time units long. Pause between dots and dashes in a character – is 1 time unit long. Pause between characters inside a word – is 3 time units long. Pause between words – is 7

Advertisement