Is a prime number

Write a function to return boolean for checking if it is a prime number.

Read More

Share Comments

Reorder an array with given indexes

We have an array of objects A and an array of indexes B. Reorder objects in array A with given indexes in array B. Do not change array A’s length.

example:

var A = [C, D, E, F, G];
var B = [3, 0, 4, 1, 2];
sort(A, B);
// A is now [D, F, G, C, E];

Read More

Share Comments

Pascal's triangle

Write a function to return the nth row in Pascal’s triangle

For example,
getRow(1) returns 1
getRow(2) returns 1 1
getRow(3) returns 1 2 1
getRow(4) returns 1 3 3 1

Read More

Share Comments

The First Post

My very first post

First

Read More

Share Comments