Skip to content
Advertisement

Convert items of a list of lists with different format conversion

I have the following list of lists (denoted by lol):

JavaScript

I am trying to convert lol in such a way that each first three strings of a sub-list to be converted to int and each last string of the same sub-list to be converted to datetime (dateConverter() is to convert string to daytime).

I am expecting to have as output the following:

JavaScript

I tried the following:

  1. I knew how to convert the first three strings to int.
JavaScript
  1. I knew how to convert the last string to daytime.
JavaScript
  1. I did not know how to do that 2-in-1 using map function or any other way. I tried the following but did not work for me.
JavaScript

Advertisement

Answer

What about this?

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement