1/* 2 Copyright (c) 2023 Huawei Device Co., Ltd. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 * 7 http://www.apache.org/licenses/LICENSE-2.0 8 * 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 */ 15 16 17try { 18 try { 19 a = 1; 20 } catch (e) { 21 a; 22 } 23 if (a == "") { 24 throw "null"; 25 } 26 if (x > 100) { 27 throw "max"; 28 } else { 29 throw "min"; 30 } 31} 32catch (err) { 33 func0(a, 10); 34} 35finally { 36 console.log("error"); 37} 38 39var car = ["B", "V", "p", "F", "A"]; 40var text = ""; 41var i; 42for (i = 0; i < 5; i++) { 43 text += car[i] + x + y; 44} 45 46function func0(x, y) { 47 var a = x + y; 48 var text = ""; 49 if (isNaN(x)) { 50 text = "number is invalid"; 51 } else { 52 text = (x < 18) ? "young" : "old"; 53 } 54 return a; 55} 56 57function func1(x, y) { 58 var arr = ["B", "V", "p", "F", "A"]; 59 let text = ""; 60 for (let x of arr) { 61 text += x; 62 } 63 while (i < 5) { 64 text += "The number is " + i; 65 i++; 66 } 67 do { 68 text += "The number is " + i; 69 i++; 70 } 71 while (i < 5); 72 } 73 74 function func2(x, y) { 75 var arr = ["B", "V", "p", "F", "A"]; 76 for (let x of arr) { 77 y += x; 78 } 79 var arr = ["B", "V", "p", "F", "A"]; 80 81 for (let x of arr) { 82 y += x; 83 } 84 return y; 85 }