JavaScript入门与实战:从基础到游戏开发
1. JavaScript基础代码示例
以下是一个简单的JavaScript代码示例,用于输出经典的“99瓶啤酒在墙上”的歌词:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My First JavaScript</title>
</head>
<body>
<script>
var word = "bottles";
var count = 99;
while (count > 0) {
console.log(count + " " + word + " of beer on the wall");
console.log(count + " " + word + " of beer,");
console.log("Take one down, pass it around,");
count = count - 1;
if (count > 0) {
console.log(count + " " + word + " of beer on the wall.");
} else {
console.log("No more " + word + "
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



