Ad
Code
Diff
  • function monteCarlo(shouldResolve) {
      return new Promise(function (resolve, reject) {
        if(!shouldResolve) reject('Oh no, the promised was rejected!');
        
        resolve({ title: 'UOL - O Melhor conteúdo' });
      });
    }
    
    async function main(shouldResolve) {
      try {
        const getMonteCarlo = await monteCarlo(shouldResolve);
        return getMonteCarlo.title;
      }
      catch(e) {
        return e;
      }
    }
    • function monteCarlo() {
    • function monteCarlo(shouldResolve) {
    • return new Promise(function (resolve, reject) {
    • resolve([{
    • titulo: 'UOL - O Melhor conteúdo'
    • }]);
    • if(!shouldResolve) reject('Oh no, the promised was rejected!');
    • resolve({ title: 'UOL - O Melhor conteúdo' });
    • });
    • }
    • async function main() {
    • // converter para ES6
    • monteCarlo().then(function(response) {
    • console.log(response)
    • });
    • return true;
    • async function main(shouldResolve) {
    • try {
    • const getMonteCarlo = await monteCarlo(shouldResolve);
    • return getMonteCarlo.title;
    • }
    • catch(e) {
    • return e;
    • }
    • }
Code
Diff
  • const main = () => {
      const a = [1, 2, 3];
      const b = [4, 5, 6];
      const c = [7, 8, 9];
      
      return [...a, ...b, ...c].join(',');
    }
    • const main = () => {
    • let a = [1, 2, 3];
    • const a = [1, 2, 3];
    • const b = [4, 5, 6];
    • const c = [7, 8, 9];
    • let b = [4, 5, 6];
    • let c = [7, 8, 9];
    • // converter para ES6
    • var d = a.concat(b).concat(c);
    • return d.join(',');
    • return [...a, ...b, ...c].join(',');
    • }