鸿蒙ArkTS 核心篇-13-if分支语句

目录

根据逻辑条件结果,执行不同语句

[if -else](#if -else)

[if-else if-else](#if-else if-else)

[DevEco Studio代码实战](#DevEco Studio代码实战)

[ctrl + s 日志输出](#ctrl + s 日志输出)

总结


根据逻辑条件结果,执行不同语句

if -else

if-else if-else

DevEco Studio代码实战

TypeScript 复制代码
let age: number = 10

if (age >= 18) {
  console.log('成年了,可以上网吧')
} else {
  console.log('孩砸,回家写作业吧')
}

let score: number = 58

if (score >= 80) {
  console.log('成绩评价为 A')
} else if (score >= 70) {
  console.log('成绩评价为 B')
} else if (score >= 60) {
  console.log('成绩评价为 C')
} else {
  console.log('没及格,再接再厉')
}


@Entry
@Component
struct Index {
  build() {

  }
}

ctrl + s 日志输出

总结

相关推荐
OH_TPC3 小时前
HarmonyOS APP开发---"菜谱汇"美食菜谱App,需要用到这个库
harmonyos
老陈说编程3 小时前
2. 鸿蒙(HarmonyOS)超级终端与生态
华为·harmonyos
2501_919749035 小时前
华为鸿蒙免费时钟工具—小羊时钟
华为·harmonyos
aqi0015 小时前
鸿蒙版本的电子书阅读APP开放源码啦
android·华为·ai编程·harmonyos·鸿蒙
xq952719 小时前
HDC Assistant 插件横空出世
harmonyos
垆边人似月.21 小时前
华为机试题 :两数之和
c++·算法·华为
垆边人似月.21 小时前
华为机试题 :有效的括号
c++·算法·华为
高德开放平台1 天前
高德开放平台×华为:一句话,开启腕上打车
华为
垆边人似月.1 天前
华为机试题 :字符串压缩
算法·华为