回答編集履歴
5
typo
    
        answer	
    CHANGED
    
    | @@ -45,6 +45,19 @@ | |
| 45 45 | 
             
                return resolve();
         | 
| 46 46 | 
             
              },plist[n].wait);
         | 
| 47 47 | 
             
            });
         | 
| 48 | 
            +
            Promise.all([p(0),p(1),p(2)]).then(()=>{
         | 
| 49 | 
            +
                console.log('step 1');
         | 
| 50 | 
            +
                Promise.all([p(3),p(4),p(5)]).then(()=>{
         | 
| 51 | 
            +
                  console.log('step 2');
         | 
| 52 | 
            +
                  Promise.all([p(6),p(7),p(8)]).then(()=>{
         | 
| 53 | 
            +
                    console.log('end');
         | 
| 54 | 
            +
                  });
         | 
| 55 | 
            +
                });
         | 
| 56 | 
            +
            });
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            ```
         | 
| 59 | 
            +
            # 参考
         | 
| 60 | 
            +
            ```javascript
         | 
| 48 61 | 
             
            const plist=[
         | 
| 49 62 | 
             
              {text:"1",wait:1000},
         | 
| 50 63 | 
             
              {text:"2",wait:0},
         | 
| @@ -62,20 +75,6 @@ | |
| 62 75 | 
             
                return resolve();
         | 
| 63 76 | 
             
              },plist[n].wait);
         | 
| 64 77 | 
             
            });
         | 
| 65 | 
            -
             | 
| 66 | 
            -
            Promise.all([p(0),p(1),p(2)]).then(()=>{
         | 
| 67 | 
            -
                console.log('step 1');
         | 
| 68 | 
            -
                Promise.all([p(3),p(4),p(5)]).then(()=>{
         | 
| 69 | 
            -
                  console.log('step 2');
         | 
| 70 | 
            -
                  Promise.all([p(6),p(7),p(8)]).then(()=>{
         | 
| 71 | 
            -
                    console.log('end');
         | 
| 72 | 
            -
                  });
         | 
| 73 | 
            -
                });
         | 
| 74 | 
            -
            });
         | 
| 75 | 
            -
             | 
| 76 | 
            -
            ```
         | 
| 77 | 
            -
            # 参考
         | 
| 78 | 
            -
            ```javascript
         | 
| 79 78 | 
             
            (async ()=>{
         | 
| 80 79 | 
             
              await (async (...args)=>{await Promise.all(args.map(arg=>p(arg)));})(0,1,2);
         | 
| 81 80 | 
             
              console.log("step 1");
         | 
4
all
    
        answer	
    CHANGED
    
    | @@ -45,6 +45,23 @@ | |
| 45 45 | 
             
                return resolve();
         | 
| 46 46 | 
             
              },plist[n].wait);
         | 
| 47 47 | 
             
            });
         | 
| 48 | 
            +
            const plist=[
         | 
| 49 | 
            +
              {text:"1",wait:1000},
         | 
| 50 | 
            +
              {text:"2",wait:0},
         | 
| 51 | 
            +
              {text:"3",wait:500},
         | 
| 52 | 
            +
              {text:"4",wait:0},
         | 
| 53 | 
            +
              {text:"5",wait:1000},
         | 
| 54 | 
            +
              {text:"6",wait:500},
         | 
| 55 | 
            +
              {text:"7",wait:500},
         | 
| 56 | 
            +
              {text:"8",wait:1000},
         | 
| 57 | 
            +
              {text:"9",wait:0},
         | 
| 58 | 
            +
              ];
         | 
| 59 | 
            +
            const p=n=>new Promise((resolve)=>{
         | 
| 60 | 
            +
              setTimeout(()=>{
         | 
| 61 | 
            +
                console.log(plist[n].text);
         | 
| 62 | 
            +
                return resolve();
         | 
| 63 | 
            +
              },plist[n].wait);
         | 
| 64 | 
            +
            });
         | 
| 48 65 |  | 
| 49 66 | 
             
            Promise.all([p(0),p(1),p(2)]).then(()=>{
         | 
| 50 67 | 
             
                console.log('step 1');
         | 
3
調整
    
        answer	
    CHANGED
    
    | @@ -60,11 +60,11 @@ | |
| 60 60 | 
             
            # 参考
         | 
| 61 61 | 
             
            ```javascript
         | 
| 62 62 | 
             
            (async ()=>{
         | 
| 63 | 
            -
              await (async ()=>{await Promise.all( | 
| 63 | 
            +
              await (async (...args)=>{await Promise.all(args.map(arg=>p(arg)));})(0,1,2);
         | 
| 64 64 | 
             
              console.log("step 1");
         | 
| 65 | 
            -
              await (async ()=>{await Promise.all( | 
| 65 | 
            +
              await (async (...args)=>{await Promise.all(args.map(arg=>p(arg)));})(3,4,5);
         | 
| 66 66 | 
             
              console.log("step 2");
         | 
| 67 | 
            -
              await (async ()=>{await Promise.all( | 
| 67 | 
            +
              await (async (...args)=>{await Promise.all(args.map(arg=>p(arg)));})(6,7,8);
         | 
| 68 68 | 
             
              console.log("end");
         | 
| 69 69 | 
             
            })();
         | 
| 70 70 | 
             
            ```
         | 
2
さんこう
    
        answer	
    CHANGED
    
    | @@ -56,6 +56,15 @@ | |
| 56 56 | 
             
                });
         | 
| 57 57 | 
             
            });
         | 
| 58 58 |  | 
| 59 | 
            -
             | 
| 59 | 
            +
            ```
         | 
| 60 | 
            -
             | 
| 60 | 
            +
            # 参考
         | 
| 61 | 
            +
            ```javascript
         | 
| 62 | 
            +
            (async ()=>{
         | 
| 63 | 
            +
              await (async ()=>{await Promise.all([p(0),p(1),p(2)])})();
         | 
| 64 | 
            +
              console.log("step 1");
         | 
| 65 | 
            +
              await (async ()=>{await Promise.all([p(3),p(4),p(5)])})();
         | 
| 66 | 
            +
              console.log("step 2");
         | 
| 67 | 
            +
              await (async ()=>{await Promise.all([p(6),p(7),p(8)])})();
         | 
| 68 | 
            +
              console.log("end");
         | 
| 69 | 
            +
            })();
         | 
| 61 70 | 
             
            ```
         | 
1
chousei
    
        answer	
    CHANGED
    
    | @@ -28,8 +28,7 @@ | |
| 28 28 |  | 
| 29 29 | 
             
            まとめるとこう
         | 
| 30 30 | 
             
            ```javascript
         | 
| 31 | 
            -
            var p=[];
         | 
| 32 | 
            -
             | 
| 31 | 
            +
            const plist=[
         | 
| 33 32 | 
             
              {text:"1",wait:1000},
         | 
| 34 33 | 
             
              {text:"2",wait:0},
         | 
| 35 34 | 
             
              {text:"3",wait:500},
         | 
| @@ -40,23 +39,23 @@ | |
| 40 39 | 
             
              {text:"8",wait:1000},
         | 
| 41 40 | 
             
              {text:"9",wait:0},
         | 
| 42 41 | 
             
              ];
         | 
| 43 | 
            -
            plist.forEach((x,y)=>{
         | 
| 44 | 
            -
             | 
| 42 | 
            +
            const p=n=>new Promise((resolve)=>{
         | 
| 45 | 
            -
             | 
| 43 | 
            +
              setTimeout(()=>{
         | 
| 46 | 
            -
             | 
| 44 | 
            +
                console.log(plist[n].text);
         | 
| 47 | 
            -
             | 
| 45 | 
            +
                return resolve();
         | 
| 48 | 
            -
             | 
| 46 | 
            +
              },plist[n].wait);
         | 
| 49 | 
            -
              });
         | 
| 50 47 | 
             
            });
         | 
| 48 | 
            +
             | 
| 51 | 
            -
            Promise.all([p | 
| 49 | 
            +
            Promise.all([p(0),p(1),p(2)]).then(()=>{
         | 
| 52 50 | 
             
                console.log('step 1');
         | 
| 53 | 
            -
                Promise.all([p | 
| 51 | 
            +
                Promise.all([p(3),p(4),p(5)]).then(()=>{
         | 
| 54 52 | 
             
                  console.log('step 2');
         | 
| 55 | 
            -
                  Promise.all([p | 
| 53 | 
            +
                  Promise.all([p(6),p(7),p(8)]).then(()=>{
         | 
| 56 54 | 
             
                    console.log('end');
         | 
| 57 55 | 
             
                  });
         | 
| 58 56 | 
             
                });
         | 
| 59 57 | 
             
            });
         | 
| 60 58 |  | 
| 61 59 |  | 
| 60 | 
            +
             | 
| 62 61 | 
             
            ```
         | 
