javascript 我是JS新手,我的代码有什么问题?[关闭]

mrphzbgm  于 2023-01-29  发布在  Java
关注(0)|答案(1)|浏览(133)

这个问题是由打字错误或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
昨天关门了。
Improve this question
当我在浏览器中打开html文件时,它在控制台中没有显示任何内容。它应该显示2个对象(post1和post2)。在VSC中,第20行的单词posts下有一条红线,也不知道为什么

<script>

    var post1 = {
        content: 'This is my super post', 
        likes: 30, 
        shares: 20
    }
    var post2 = {
        content: 'This is my boring post', 
        likes: 5,
        shares: 0
    }

    var facebookuser = {
        userName: 'Ahmed',
        password: 'xxxx',
        email: 'anoun123@hotmail.com',
        profileimage: 'reference-image',
        friends: ['Mike', 'Wael', 'Rami']
        posts: [post1, post2]
    }

    var posts = [post1, post2]
    for (index in posts) {
        
        console.log(posts[index])
        }
</script>

<body>

</body>
ffx8fchx

ffx8fchx1#

let post1 = {
        content: 'This is my super post', 
        likes: 30, 
        shares: 20
    }
    let post2 = {
        content: 'This is my boring post', 
        likes: 5,
        shares: 0
    }
    
    let facebookuser = {
        userName: 'Ahmed',
        password: 'xxxx',
        email: 'anoun123@hotmail.com',
        profileimage: 'reference-image',
        friends: ['Mike', 'Wael', 'Rami'],
        posts:[post1, post2]
    }
    
    for (index in facebookuser.posts) {
        console.log(facebookuser.posts[index]);
    }

相关问题