Rosetta Code: Convert seconds to compounds solution

Greetings, developers!

I did this Rosetta Code challenge but I still feel that nonetheless I’ve been coding everyday for months I still write too much to do some simple funcionalities and sometings write O(n²) codes knowing that probably there is an O(n log(n)) .
Im not only reducing complexity but I’m not used to think first how to use High Order Functions like map.

So, here’s my code and if you’re interested please share your resolutions.

> function convertSeconds(sec) {
>   const units = [
>     ["wk",604800],
>     ["d",86400],
>     ["hr",3600],
>     ["min",60],
>     ["sec",1]
>     ];
>   let result = [];
>   let string = "";
>   let index=0;
>   for(index=0; sec > 0 ;index++){
>       if(Math.floor(sec/units[index][1])){
>         result.push(Math.floor(sec/units[index][1])+" "+units[index][0]);
>         sec -= Math.floor(sec/units[index][1])*units[index][1];
>       }
>   }
>   for(index=0;index<result.length-1;index++){
>     string+=result[index] + ", " ;
>   }
>   string+=result[index]
>   return string;
> }
> 
> console.log(convertSeconds(6000000));

Hi there; do you have a question?

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Oh, Sorry!
I think there’s a solution with fewer lines and I’m hoping that somebody share it with me, actually.
Thanks for the advice!