0

I should have an array of account objects, an account object should be composed by a username and password property e.g:

var account = {
     username: '[email protected]',
     password: 'UG384'
};

It should be like this, but it is

accounts = ['[email protected]:HAS8324', and so forth]
2
  • How does UG384 convert to HAS8324? Commented May 4, 2021 at 15:13
  • I don't think that was intentional, [email protected] becomes [email protected] as well, I think they are just different random filler text, the author should be a little more consistent though Commented May 4, 2021 at 15:19

1 Answer 1

-1

Simply use Object.values return only values of an abject, and data destruction to get user and pass and merge them together using template literal:

[user, pass] = Object.values(account);
res = `${user}:${pass}`;//"[email protected]:UG384"
Sign up to request clarification or add additional context in comments.

6 Comments

they need [ "[email protected]:UG384" ], not [ "[email protected]", "UG384" ]
"I have an array of strings, 'email:password'. With these strings, and I need to turn it into an object that separates these values"
@andymccullough [ "[email protected]:UG384" ] is their input from the question title
gotcha, misread it
@andymccullough the title and the body of the question is very misleading and confusing
|