This file contains 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
let events = [ | |
{title: "lowest scored event", score: "1.23"}, | |
{title: "highest scored event", score: "4.05"}, | |
{title: "middle scored event", score: "3.75"} | |
] | |
function maxScoredEvent(events){ | |
return events.reduce((p,c) => { | |
return p.score > c.score ? p : c | |
}) |
This file contains 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
function bracketChecker(str){ | |
let match = {"}":"{", "]":"[", ")":"("} | |
let opening = ["(", "[", "{"] | |
let toClose = [] | |
for (let i = 0; i < str.length; i++){ | |
if (opening.includes(str[i])){ | |
toClose.push(str[i]) | |
} else { | |
if (toClose[toClose.length-1] !== match[str[i]]){ | |
return false |
This file contains 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
const express = require('express') | |
// import the Express module | |
const app = express() | |
// create an Express application that has Express' built-in functionality, such as routing | |
app.get('/', (req, res) => res.send('Hello World!')) | |
// define a route (this one is a GET request to 'domainname.com/', in this case, 'localhost:3000/'. When the request is recieved, it will respond with the string "Hello World!") | |
app.listen(3000, () => console.log('Example app listening on port 3000!')) | |
// this defines the port that the server should run (3000) and logs that it's running. By running this file (' node filename.js'), the server will start, and you'll see 'Hello World!' by visiting localhost:3000/. |
This file contains 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
const http = require('http'); | |
const hostname = '127.0.0.1'; | |
const port = 3000; | |
const server = http.createServer((req, res) => { | |
res.statusCode = 200; | |
res.setHeader('Content-Type', 'text/plain'); | |
res.end('Hello World!'); | |
}); |
This file contains 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
function concat(first, last){ | |
return `${first} ${last}` | |
} | |
function greet(f, l){ | |
console.log(`Hi, ${concat(f, l)}`) | |
} | |
greet("Gabi", "Granger") |
This file contains 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
function eventLoop(){ | |
setTimeout(() => {console.log(3)},0) | |
console.log(1) | |
return 2 | |
} | |
eventLoop() |
This file contains 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
class ClassroomsController < ApplicationController | |
def update | |
@classroom = Classroom.find(params[:id]) | |
if @classroom.update(classroom_params) | |
redirect_to users_path, :notice => "#{@classroom.name} updated" | |
else | |
flash[:notice] = "Classrooms must have a name" | |
@programs = Program.all | |
render :edit |
This file contains 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
class ClassroomsController < ApplicationController | |
def update | |
@classroom = Classroom.find(params[:id]) | |
if @classroom.update(classroom_params) | |
program_ids = classroom_program_params[:program_ids].delete_if {|program| program == ""} | |
@programs = program_ids.map {|id| Program.find(id)} | |
@classroom.update(programs: @programs) | |
redirect_to users_path, :notice => "#{@classroom.name} updated" | |
else | |
flash[:notice] = "Classrooms must have a name" |
This file contains 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
<%= f.collection_check_boxes(:program_ids, @programs, :id, :title) do |b| %> | |
<div> <%= b.check_box %><%= b.label { b.text } %></div> | |
<% end %> | |
<% end %> |
This file contains 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
<%= f.collection_check_boxes :program_ids, @programs, :id, :title %> |
NewerOlder