Skip to content

Instantly share code, notes, and snippets.

@JoanClaret
Created March 12, 2018 15:24
Show Gist options
  • Save JoanClaret/25c4cfb8d183b1e79cc4371ab930b06f to your computer and use it in GitHub Desktop.
Save JoanClaret/25c4cfb8d183b1e79cc4371ab930b06f to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kabijox
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
const suma = (number) => new Promise((resolve, reject) => setTimeout(() => resolve(number + number), 2000))
suma(2).then((response)=> suma(response).then((response) => console.log(response)))
const foo = async (x) => {
const a = await suma(2);
const b = await suma(2);
return x + a + b;
}
foo(10).then(v => {
console.log(v);
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">const suma = (number) => new Promise((resolve, reject) => setTimeout(() => resolve(number + number), 2000))
suma(2).then((response)=> suma(response).then((response) => console.log(response)))
const foo = async (x) => {
const a = await suma(2);
const b = await suma(2);
return x + a + b;
}
foo(10).then(v => {
console.log(v);
});</script></body>
</html>
const suma = (number) => new Promise((resolve, reject) => setTimeout(() => resolve(number + number), 2000))
suma(2).then((response)=> suma(response).then((response) => console.log(response)))
const foo = async (x) => {
const a = await suma(2);
const b = await suma(2);
return x + a + b;
}
foo(10).then(v => {
console.log(v);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment