Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

draw diamond in typescript

function diamond(val) {
  let y,
    w,
    shape = '';

  for (y = 0; y < val * 2 - 1; y++) {
    w = y < val ? y : val * 2 - y - 2;
    shape += Array(val - w).join(' ') + Array(w + 1).join('* ') + '*
';
  }
  console.log(shape);
}

diamond(4);
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to install reveal.js from node 
Javascript :: what is steal.js 
Javascript :: paamayim nekudotayim 
Javascript :: nested table jquery datatable 
Javascript :: f and j keys 
Javascript :: javascript middleware getter and setter 
Javascript :: firebase remove not valid token 
Javascript :: edit jquery-connections 
Javascript :: how to render file vue template in javascript with gulp 
Javascript :: append new element for each value in array d3.js 
Javascript :: pegar qual domínio eu estou javascript 
Javascript :: show data of mongoose in html page using ejs 
Javascript :: dropdown list value react fragment 
Javascript :: filter keys from object using ramda 
Javascript :: how to write a program that determines the minutes since midnight, Jan 1, 1970 in javascript 
Javascript :: Cypress.currentTest 
Javascript :: can you wrap redux provider within react.strictmode 
Javascript :: replace array element javascript stack overflow 
Javascript :: vuejs use set to prevent duplicates 
Javascript :: angular file upload app with django 
Javascript :: refresh javascript using require 
Javascript :: react generate ethereum address 
Javascript :: deconstruction javascript check if exist attrib 
Javascript :: console log update status bar 
Javascript :: setup node and mongodb on centos 7 using npm 
Javascript :: youtube movie trailer angular 
Javascript :: kendo treeview get element 
Javascript :: onclick start and stop the count react 
Javascript :: js set visibility on timeout 
Javascript :: Ajax send date to MVC 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =