Created
October 4, 2013 22:27
-
-
Save MiriamNeubauer/6833876 to your computer and use it in GitHub Desktop.
Hello, this is my first quiz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // #1 | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="/script/script.js" type="text/javascript"></script> | |
| <link rel="sytlesheet" type="text/css" href="/style/style.css"> | |
| </head> | |
| // #2 | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script type="text/javascript" src="/script/script_1.js"></script> | |
| <script type="text/javascript" src="/script/script_2.js"></script> | |
| </head> | |
| // #3 | |
| // If the CLICK ME button is clicked twice what does the console display? | |
| // html (the error isn't here) | |
| … | |
| <button id="someId">CLICK ME</button> | |
| … | |
| // JS | |
| … | |
| var count = 0; | |
| function clickAction(){ | |
| count + 1; | |
| console.log("hello "+ count) | |
| } | |
| document.getElementById("someId").onclick = clickAction() | |
| … | |
| // Answer: hello 2 | |
| // #4 | |
| var count = 0; | |
| function countPlusTenSquared(){ | |
| var increment = 10; | |
| count = count + increment; | |
| return count*count; | |
| } | |
| // #5 | |
| <form action="/" method="get"> | |
| <input type="text" name="my_name"> | |
| <input type="submit" value="submit name"> | |
| </form> | |
| // #6 | |
| … | |
| get "/double/:my_number" do | |
| input = params[:my_number] | |
| @double = 2*input.to_i | |
| erb :show | |
| end | |
| // Answer for what "/double/2" returns: 4 | |
| // #7 | |
| // app.rb | |
| get "/greet/:name" do | |
| @submitted_name = params[:name] | |
| erb :show | |
| end | |
| // show.erb | |
| <div> | |
| Hello <%= @submitted_name %>! | |
| </div> | |
| // When I go to /greet/world expecting Hello World!, but I get the following error: | |
| // NameError at `/greet/world` | |
| // undefined local variable or method `id' for | |
| // #<Sinatra::Application:0x007f892315d160> | |
| // BACKTRACE | |
| // ____________________________________________ | |
| // 2. <%= submitted_name %> | |
| // #8 | |
| // Is this RESTful? | |
| // I have a site http://somelist.com that stores peoples names in a list. | |
| // I made the following routes | |
| GET '/name/new' # for showing a new form | |
| GET '/name/create' # for submiting a 'new' name form, | |
| # and creating | |
| GET '/name/:id/delete' # for submitting a deleting for a name | |
| GET '/name/:id/edit' # for showing a new edit form | |
| GET '/name/:id/edit/post' # for submitting an edit | |
| # from a form | |
| // Answer: (My notes: get-post-delete-patch.) They use GET for everything. | |
| // That is fine for /name/new and /name/create. /name/:id/delete should | |
| // use DELETE instead of GET, and /name/:id/edit/post shoudl use POST instead of GET. | |
| // #9 | |
| // What do you think of my controller? I don't even need a view. Why shouldn't I put all this in my controller? | |
| get "/" do | |
| pageTitle = "myApp!" | |
| "<!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>#{pagetitle}</title> | |
| </head> | |
| <body> | |
| <div> | |
| Hello there! | |
| </div> | |
| </body> | |
| </html>" | |
| end | |
| // Answer: Because the controller is here to execute functionalties and not layout and style. | |
| // #10 | |
| // Look at my view! This works, but why should I be doing things this way? | |
| // app.rb | |
| get '/person/:name' do | |
| erb :show | |
| end | |
| // show.erb | |
| <div> | |
| <% person = params[:name] %> | |
| Hello <%= person %> | |
| </div> | |
| // Answer: because it helps creating code that is easy to change?! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice work Miriam!
Look at the name, in #1 - it says "sytlesheet", so that wouldn't work :)
It looks like you've really gotten the bigger picture, but may sometimes struggle with syntactical details. You will get better at spotting those little details with practice!