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 17function func(num) { 18 if (num > 0) { 19 num = 0; 20 } else { 21 num += 1; 22 } 23 return num; 24} 25 26function func1(num1, num2) { 27 const num = 1; 28 try { 29 if (num1 > num2) { 30 num1 += num; 31 console.log('succes.'); 32 } 33 else { 34 throw new Error('the number is low.'); 35 } 36 } 37 catch (err) { 38 console.log('error message: ' + err); 39 } 40} 41 42function func2(x, y) { 43 var car = ["B", "V", "p", "F", "A"]; 44 var text = ""; 45 var i; 46 for (i = 0; i < 5; i++) { 47 text += car[i] + x + y; 48 } 49 return text; 50} 51 52function func3(a, b, c, d, e) { 53 return a + b + c + d + e; 54} 55 56function func4(x, y) { 57 var a = x + y; 58 var b = x - y; 59 var c = x * y; 60 var d = x / y; 61 var e = x % y; 62 return func3(e, d, c, b, a); 63} 64 65function func5() { 66 try { 67 try { 68 a = 1; 69 } catch (e) { 70 a; 71 } 72 if (a > 0) { 73 a += 1; 74 } else { 75 throw new Error('the number is low.'); 76 } 77 } catch (e) { 78 print(e); 79 } 80} 81 82