0

This is my code so far BUT I would like to make it look more sophisticated or at least styled. How can I at least list the array vertically?

var http = require('http');

statescaps = new Array("Alabama,Montgomery","Alaska,Juneau","Arizona,Phoenix","Arkansas,Little Rock","California,Sacramento","Colorado,Denver","Connecticut,Hartford","Delaware,Dover","Florida,Tallahassee","Georgia,Atlanta","Hawaii,Honolulu","Idaho,Boise","Illinois,Springfield","Indiana,Indianapolis","Iowa,Des Moines","Kansas,Topeka","Kentucky,Frankfort","Louisiana,Baton Rouge","Maine,Augusta","Maryland,Annapolis","Massachusetts,Boston","Michigan,Lansing","Minnesota,St. Paul","Mississippi,Jackson","Missouri,Jefferson City").sort()

http.createServer(function (req,res) {
    res.writeHead(200, {'Content-Type':'text/plain'});
    res.write("here are 25 US States and their Capitals:" + statescaps);
    res.end();
}).listen(8080);

1 Answer 1

0

To list the states vertically, you can join the array using newline characters:

res.write("here are 25 US States and their Capitals:\n" + statescaps.join('\n');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.