Home > Web Front-end > JS Tutorial > How to draw js hollow graphics quickly

How to draw js hollow graphics quickly

巴扎黑
Release: 2016-11-25 11:54:41
Original
1548 people have browsed it

/*空心直角三角形*/

    for (var i = 0; i < 10; i++) {

        (i == 0 || i == 9) ? document.write(Array(i + 2).join("* ") + "
") : document.write("*" + Array(i + 1).join("   ") + "*
");

    }

    /*空心菱形*/

    var arr = [];

    for (var p = 0; p < 6; p++) {

        (p == 0) ? arr.push(Array(6).join("   ") + "*
") : arr.push(Array(6 - p).join("   ") + "*" + Array(p * 2 + 1).join("   ") + "*
");

    }

    (document.write(arr.join("")), arr.pop(), document.write(arr.reverse().join("")));


Related labels:
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template