day4- JS

python

name = '123'

age = 23

print(f '姓名: {name}')
JS

            // 变量数组元素
            let nums = [1, 2, 3, 4, 5]
            // for (let idx = 0; idx < nums.length; idx += 1) {
            //  alert(nums[idx])
            // }
            for (num of nums) {
                alert(num)
            }
            
            // 遍历对象属性
            let stu = {
                name: 'Z',
                age:44,
                sex:'男',
                friends:['h', 'y'],
                car: {
                    'brand': 'QQ',
                    'maxSpeed':'55'
                }
            }
            for (prop in stu) {
                alert(stu[prop])
            }

乘法表

      for ( let i = 1; i <= 9; i += 1) {
                document.write('

') for (let j = 1; j <= i; j += 1) { document.write(`${i}×${j}=${i * j}  `) } document.write('

') }

你可能感兴趣的:(day4- JS)