Challenge 12 Megathread

Can’t put 2 images in the same post, so here’ s the original code:

image

image

Two passed tests but getting [object Object} instead of expected message. Kind of lost on this one.

This one is written in such a way that it can and will confuse a lot of people… something not uncommon in the real world!

My advice: slow down, reread the specs of the challenge. What default content is being passed in messages for the tests, and what is the expected output. Keep that in mind, and remember that the solution is less complicated than you think it is.

3 Likes

2 passing tests but still getting the message [Object Object]. Here is my code

The concat() method returns a new array, containing the joined arrays. It doesn’t modify messages.

1 Like

I did hard code the values for messages in my code and submitted it before the bug is solved. Is that mean it is not correct?

Thank you! I will try to fix it

1 Like

You’re a warrior! programming in a cellphone! :muscle:

2 Likes

Did I tell you that I program in a cellphone while my 1-year-old daughter is sleeping ?:sweat_smile:

5 Likes

This is some good advice. I have been surprised how many of the challenges have had legit 1 line solutions so far.

1 Like

:scream:
And you’re still multi-tread!! Wow!

1 Like

I’m a bit lost while reading your code because I’m not familiar with obj.concat( ).
Is your code returning an array of strings?

I am not familiar too! But It’s returning an array of these objects (if I understood right). I don’t think concat applies here , I tried .push, but still not getting the expected output

I believe that concat is appending or joining the first array “messages”, which contains one or more objects, with the strings you are creating inside the loop. You may want to declare a new variable of type Array in which to store the strings.

Thank you! I will try that

Totally lost on this one. Likely overthinking, but just not getting it.

I got this!
I created a new array
Made a forEach loop
Push my string into the new array
And return my new array

3 Likes

Look at the post by @rkrc, should give you a good outline to solving this! You can also use the function that you wrote in challenge 1 to make one of the tasks easier :slight_smile:

1 Like

My code passed on the first try. Which was a big WTF surprise for me… I thought I had at least got some syntax wrong somewhere.

The logic behind my code was like this:

  1. create a parseMessage function at the beginning that will take in one line of input and convert it to the desired format (copy-pasted my function from first challenge). only 1 line required in function - return

  1. inside the parse transcript function: create an output array variable with the value []
var output = []
  1. create a loop for the array, same as one of the previous challenges. Can copy paste again.

  1. inside the loop, push the parsed message to the output using the function from before

  1. then return output

I was surprised it worked on my first try as I thought I had messed up the first function by not putting entry[x].origin or similar… but it worked fine.

I hope this is helpful to people.

Some parts of this post is deleted by the moderators. Please don’t share the correct code.

I am having a similar issue and can’t figure it out. Even tried break; but didn’t work