Promise
is a constructor function so you need to use the new
keyword to create one. It takes a function as its argument with two parameters, resolve
and reject
. These are methods used to determine the outcome of the promise. The syntax looks like this:
=======
A promise in javascript is exactly what it sounds like. You use it to make a promise to do something, and at some point you either fulfill your promise or fail to do so. It’s a constructor function, so they are create with the new
keyword. It needs a function as its argument with two parameters, resolve
and reject
. These are methods used to determine the outcome of the promise. The syntax looks like this:
>>>>>>> 5aba19817... feat/new-lessons-on-js-promises
=======
A promise in javascript is exactly what it sounds like. You use it to make a promise to do something, usually asynchronous. When the task completes you either fulfill your promise or fail to do so. It’s a constructor function, so they are created with the new
keyword. It needs a function as its argument with two parameters, resolve
and reject
. These are methods used to determine the outcome of the promise. The syntax looks like this:
>>>>>>> 396e6142b... fix/update-verbiage
=======
A promise in JavaScript is exactly what it sounds like. You use it to make a promise to do something, usually asynchronously. When the task completes you either fulfill your promise or fail to do so. Promise
is a constructor function so you need to use the new
keyword to create one. It needs a function as its argument with two parameters, resolve
and reject
. These are methods used to determine the outcome of the promise. The syntax looks like this:
>>>>>>> d86e97264... Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.english.md
=======
A promise in JavaScript is exactly what it sounds like. You use it to make a promise to do something, usually asynchronously. When the task completes you either fulfill your promise or fail to do so. Promise
is a constructor function so you need to use the new
keyword to create one. It takes a function as its argument with two parameters, resolve
and reject
. These are methods used to determine the outcome of the promise. The syntax looks like this:
>>>>>>> 915a966f1... fix/change-needs-to-takes-in-instructions
```js
const myPromise = new Promise((resolve, reject) => {
});
```
makeServerRequest
. Pass in a function with resolve
and reject
parameters to the constructor.
=======
Create a new promise called makeServerRequest
. Pass in a function with resolve
and reject
parameters to the promise.
>>>>>>> 5aba19817... feat/new-lessons-on-js-promises
=======
Create a new promise called makeServerRequest
. Pass in a function with resolve
and reject
parameters to the constructor.
>>>>>>> 79a812601... Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.english.md
makeServerRequest
.
testString: assert(makeServerRequest instanceof Promise);
- text: Your promise should receive a function with resolve
and reject
as parameters.
testString: assert(code.match(/Promise\(\s*(function\s*\(\s*resolve\s*,\s*reject\s*\)\s*{|\(\s*resolve\s*,\s*reject\s*\)\s*=>\s*{)[^}]*}/g));
=======
- text: Your promise should be in a variable called makeServerRequest
.
=======
- text: You should assign a promise to a declared variable named makeServerRequest
.
>>>>>>> 8f4cfb0e5... Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.english.md
testString: assert(makeServerRequest instanceof Promise);
- text: Your promise should receive a function with resolve
and reject
as parameters.
<<<<<<< HEAD
<<<<<<< HEAD
testString: assert(typeof(makeServerRequest) === "object" && (code.match(/new\s*Promise\(\s*\(\s*resolve\s*,\s*reject\s*\)\s*=>\s*{/g) || code.match(/new\s*Promise\s*\(\s*function\s*\(\s*resolve\s*,\s*reject\s*\)\s*{/g)));
>>>>>>> 5aba19817... feat/new-lessons-on-js-promises
=======
testString: assert(makeServerRequest instanceof Promise && (code.match(/new\s*Promise\(\s*\(\s*resolve\s*,\s*reject\s*\)\s*=>\s*{/g) || code.match(/new\s*Promise\s*\(\s*function\s*\(\s*resolve\s*,\s*reject\s*\)\s*{/g)));
>>>>>>> 066e1792e... fix/add-tests
=======
testString: assert(code.match(/Promise\(\s*(function\s*\(\s*resolve\s*,\s*reject\s*\)\s*{|\(\s*resolve\s*,\s*reject\s*\)\s*=>\s*{)[^}]*}/g));
>>>>>>> 2a76bf50c... fix/make-tests-more-robust
```