Home > Web Front-end > JS Tutorial > How to print stars with JavaScript

How to print stars with JavaScript

藏色散人
Release: 2021-10-15 14:56:33
Original
3947 people have browsed it

How to print stars in JavaScript: 1. Create a new html file; 2. Write a double for loop, with the outer loop controlling the number of rows and the inner loop controlling the number of columns; 3. Store character variables and print the specified stars on each line. That’s it.

How to print stars with JavaScript

The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.

How to print stars with JavaScript?

Create a new html file in vscode

How to print stars with JavaScript

Write two input box variables to record the numbers entered in each row and column, and str empty character variable stores the output result

How to print stars with JavaScript

Write a double for loop. The outer loop controls the number of rows and the inner loop controls the number of columns. The conditional expressions for them are written as i< ;=rows,j

How to print stars with JavaScript

#Then write the execution statement and store the character variable to print the specified star on each line.

How to print stars with JavaScript

Output after the end of for, so that we can see the stars printed on the console

How to print stars with JavaScript

Then we found There is no line break for each line, just write a line break statement after the inner loop ends.

How to print stars with JavaScript

[Recommended learning: javascript basic tutorial]

The above is the detailed content of How to print stars with JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template