0

I have an Array [[9,222,3],[9,222,4],[9,333,1],[9,333,2],[9,444,1]] whare first element is static secound element is main number and third element is sub-number

I want to create string that contain main number forward by underscore "_" and its sub numbers then Slash and continue..

solution look like 222_3_4/333_1_2/444_1

thanks in advance.

2
  • 2
    Can you explain the logic in detail? For example, how does [9,222,3],[9,222,4],[9,333,1] become 222_3_4 Commented Jul 18, 2022 at 5:38
  • ok, it is a good thing that the problem has been solved. If there is still a problem next time, it is better to add some examples and logic, which can speed up the solution. Commented Jul 18, 2022 at 6:07

1 Answer 1

2

You didn't explain the logic, but here is an example that will give you a good starting point for what you need and is similar to what I've understood.

let arrData = [
  [9, 222, 3],
  [9, 222, 4],
  [9, 333, 1],
  [9, 333, 2],
  [9, 444, 1]
].map((item) => {
  return `${item[1]}_${item[2]}_${item[0]}`;
}).join('/');

console.log(arrData);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.