while
while
Node.js
let i = 0
while (i <= 5) {
console.log(i)
i++
}
Output
0
1
2
3
4
5
Go
(there‘s no while keyword in Go but the same functionality is achieved by using for)
package main
import "fmt"
func main() {
i := 0
for i <= 5 {
fmt.Println(i)
i++
}
}
Output
0
1
2
3
4
5
