Course Work Flashcards

Review and Learn

1
Q

ES6 Set
Fill in the blanks to create and output a set with the values 1, 2, 3.

const set = ___ Set();

set.add(1).add(2). ___(3);

for(let v of set.values())

console.log(__);

A

const set = new Set();

set.add(1).add(2). add (3);

for(let v of set.values())

console.log(v);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
function asyncFunc(work) {
    return new Promise(function(resolve, reject) {
        if (work === "")
            reject(Error("Nothing"));
        setTimeout(function() {
            resolve(work);
        }, 1000);
    });
}
asyncFunc("Work 1") // Task 1
.then(function(result) {
    console.log(result);
    return asyncFunc("Work 2"); // Task 2
}, function(error) {
    console.log(error);
})
.then(function(result) {
    console.log(result);
}, function(error) {
    console.log(error);
});
console.log("End");
A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

function foo() {

  return new Promise((
, 
) => {
let result = getSomeResult();

if (result)

  resolve('Success');

else

  reject('Something went wrong');

});

}

A
function foo() {
  return new Promise(( 
 resolve , reject 
) => {
    let result = getSomeResult();
    if (result)
      resolve('Success');
    else
      reject('Something went wrong');
  });
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly