#2 Build translator map in javascript

Closed
opened 6 months ago by stevet · 0 comments
let basic = "abcdefghijklmnopqrstuvwxyz0123456789".split("");
let keys = "ijklmnopqrstuvwxyz0123456789abcdefgh".split("");

// let translator = basic.map((key, index) => ( { [key]: keys[index]}));
// let translator = basic.map((key, index) => ( { [key]: keys[index]}));

let translator = basic.reduce((c, e, i) => {
    c[[e]] = keys[i];
    return c;
}, {".": ""});

console.log(translator);
```js let basic = "abcdefghijklmnopqrstuvwxyz0123456789".split(""); let keys = "ijklmnopqrstuvwxyz0123456789abcdefgh".split(""); // let translator = basic.map((key, index) => ( { [key]: keys[index]})); // let translator = basic.map((key, index) => ( { [key]: keys[index]})); let translator = basic.reduce((c, e, i) => { c[[e]] = keys[i]; return c; }, {".": ""}); console.log(translator); ```
Sign in to join this conversation.
No Milestone
No assignee
1 Participants
Loading...
Cancel
Save
There is no content yet.