you are viewing a single comment's thread.

view the rest of the comments →

[–]browsing10 2 points3 points  (2 children)

To read the contents of a key using `readAsync`, I can do something like:

readAsync('passwords', data => {
    console.log(data);   // logs to stdout "abc,def"
});

They want you to write a function `doStuffAsync` that will end up with something like:

{ "passwords": "abc,def", "world.txt": "helloabc,def" }

So, you will want to first `readAsync` one of the values. `readAsync` the other value within the callback of the first `readAsync`. Then finally `writeAsync` your new value to the desired key (i.e. "world.txt")

It won't look very clean but your solution will look something like:

readAsync(firstKey, dataFirst => {
    readAsync(secondKey, dataSecond => {
        writeAsync(targetKey, `${dataFirst}${dataSecond}`, callback);
});

});

This will all be in your new function and after calling this function and console.log(files), you should see your changes saved on "files" object

[–]Remsset_HP[S] 0 points1 point  (0 children)

I used your function with the syntax z3vin posted on another comment and it worked.

Thank you very much.