Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

288
Visualizações
TypeScript: How to specify a reference column and copy its value to remaining columns?

I have a table that looks like this:

+-------+-------+-------+-------+-------+
| Week1 | Week2 | Week3 | Week4 | Week5 |
+-------+-------+-------+-------+-------+
| AAAAA | BBBBB | CCCCC | DDDDD | EEEEE |
+-------+-------+-------+-------+-------+

I would like to write a function that:

  • Input: (1) reference column name (2) a list of impacted column name
  • Output: impacted column values changed to the same as the reference column

For example: function(1,2) means: copy Week 1 value to Week 2

+-------+-------+-------+-------+-------+
| Week1 | Week2 | Week3 | Week4 | Week5 |
+-------+-------+-------+-------+-------+
| AAAAA | AAAAA | CCCCC | DDDDD | EEEEE |
+-------+-------+-------+-------+-------+

For another example:

function(1,[2,3]) means: copy Week 1 value to Week 2 and Week 3

+-------+-------+-------+-------+-------+
| Week1 | Week2 | Week3 | Week4 | Week5 |
+-------+-------+-------+-------+-------+
| AAAAA | AAAAA | AAAAA | DDDDD | EEEEE |
+-------+-------+-------+-------+-------+

For another example: function(4,[2,3,5]) means: copy Week 4 value to Week 2, Week 3, and Week 5

+-------+-------+-------+-------+-------+
| Week1 | Week2 | Week3 | Week4 | Week5 |
+-------+-------+-------+-------+-------+
| AAAAA | DDDDD | DDDDD | DDDDD | DDDDD |
+-------+-------+-------+-------+-------+

For another example: function(2,[1,3,5]) means: copy Week 2 value to Week 1, Week 3, and Week 5

+-------+-------+-------+-------+-------+
| Week1 | Week2 | Week3 | Week4 | Week5 |
+-------+-------+-------+-------+-------+
| BBBBB | BBBBB | BBBBB | DDDDD | BBBBB |
+-------+-------+-------+-------+-------+

There could be only 1 reference column, but there could be multiple impacted columns.

I am very new to TypeScript and can't wrap my head around on how to do this in TypeScript.

I am not sure if thinking this way makes sense:

  • Concatenate all of 5 Weeks' of value into a long string (25 digits)
  • Then I am able to have the index of each week (e.g. Week 1 value = str[0:4], Week 2 value = str[5:9] etc.)
  • Then just take the reference column value and replace to the impacted columns

Much appreciation for any help!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda