Why does my card deck-generating code return an empty array?

Here’s the code. When I run it, the length of newDeck is 0, so it’s clear that no Cards are being added to it…

function Card(number, suit) {
    this.number = number;
    this.suit = suit;
}

var deck = [];

function Deck() {
    for (i=2; i>13; i++) {
        for (j=1; j>4; j++) {
            var newCard = new Card(i,j);
            deck.push(newCard);
        }
    }
    return deck
}

var newDeck = new Deck();
console.log(newDeck.length);

Why does my card deck-generating code return an empty array?

read more

How to align <div> elements?

I am trying to center two elements to make columns. I also want a footer. However, They are stacked next to each other and the footer element is inline with everything. How can I format the page correctly?

h1 {
    color: #225522;
    margin: 0px 0px 0px 0px 0px;
    padding: 0px 0px 0px 0px 0px;
} 
img {
    padding-left: 5px;
    margin-top: 5px;
    margin-left: 1px;
}
p {
    font-size: 14px;
    font-color: #484848;
    font: Trebuchet MS;
}

p.heading {
    padding: 0px;
    margin: 0px;
}
#rn_section1 {
    text-align: center;
    height: 495px;
    width: 400px;
    float: left;
    padding: 10px;
    margin-left: auto;
    margin-right: auto;
}
#rn_section2 {
    text-align: center;
    height: 500px;
    width: 400px;
    float: left;
    padding: 10px;
    margin-left: auto;
    margin-right: auto;
}
#footer {
    clear: both;
    padding: 5px;
    position:relative;
    margin-bottom: inherit;
}

read more

How to align <div> elements?

I am trying to center two elements to make columns. I also want a footer. However, They are stacked next to each other and the footer element is inline with everything. How can I format the page correctly?

h1 {
    color: #225522;
    margin: 0px 0px 0px 0px 0px;
    padding: 0px 0px 0px 0px 0px;
} 
img {
    padding-left: 5px;
    margin-top: 5px;
    margin-left: 1px;
}
p {
    font-size: 14px;
    font-color: #484848;
    font: Trebuchet MS;
}

p.heading {
    padding: 0px;
    margin: 0px;
}
#rn_section1 {
    text-align: center;
    height: 495px;
    width: 400px;
    float: left;
    padding: 10px;
    margin-left: auto;
    margin-right: auto;
}
#rn_section2 {
    text-align: center;
    height: 500px;
    width: 400px;
    float: left;
    padding: 10px;
    margin-left: auto;
    margin-right: auto;
}
#footer {
    clear: both;
    padding: 5px;
    position:relative;
    margin-bottom: inherit;
}

read more

Render directory contents with sinatra

I want to render the contents of a directory via sinatra’s routing dsl

In my browser, I can access the folder like so:

file:///Users/lfender/source/onesearch/public/bower_components/swagger-ui/dist/

enter image description here

using sinatra routes, i’d like to point a route to this static directory:

get '/api-docs/' do
  root = File.join(settings.public_folder, 'bower_components', 'swagger-ui', 'dist')
  File.read(File.expand_path(root))
end

the above route will fail with Is a directory @ io_fread because I am passing in a directory rather than a file.

read more

Render directory contents with sinatra

I want to render the contents of a directory via sinatra’s routing dsl

In my browser, I can access the folder like so:

file:///Users/lfender/source/onesearch/public/bower_components/swagger-ui/dist/

enter image description here

using sinatra routes, i’d like to point a route to this static directory:

get '/api-docs/' do
  root = File.join(settings.public_folder, 'bower_components', 'swagger-ui', 'dist')
  File.read(File.expand_path(root))
end

the above route will fail with Is a directory @ io_fread because I am passing in a directory rather than a file.

read more