Home > Web Front-end > JS Tutorial > body text

How to draw js hollow graphics quickly

巴扎黑
Release: 2016-11-25 11:54:41
Original
1466 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:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!