-
Notifications
You must be signed in to change notification settings - Fork 83
finished tests; working on implementing functions #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MiHHuynh
wants to merge
32
commits into
rithmschool:master
Choose a base branch
from
MiHHuynh:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a7a05c8
finished tests; working on implementing functions
MiHHuynh f461d1a
finished cceptNumbersOnly function
MiHHuynh 2068677
finished mergeArrays function
MiHHuynh 1828583
finished mergeObjects function. all tests passed
MiHHuynh a458e2d
finished productofarray, collectstrings, contains
MiHHuynh 39ef109
finished search in recursion exercises
MiHHuynh 24b3ca6
fixed typo in recursion tests
MiHHuynh f621f0a
edited sort function to compare numbers properly
MiHHuynh f42f98e
working on binary search
MiHHuynh a772b65
lodash exercises: drop, fromPairs
MiHHuynh ca2195c
head, take, takeRight, union, zipObject
MiHHuynh 0d0e826
includes, sample, cloneDeep
MiHHuynh ef62251
some more functions for lodash exercise
MiHHuynh 2beb2c8
added pickBy, omitBy
MiHHuynh fc8cca5
lodash functions, working on flatten
MiHHuynh e8ea7cd
initial commit for new pull request
MiHHuynh f986863
finished canvas shapes game
MiHHuynh 608e512
removed repeated code
MiHHuynh 1c272a4
removed some unnecessary elses
MiHHuynh 8198184
removed if statement in expand
MiHHuynh d0f6d3e
implemented replaceWith using a map instead of forEach
MiHHuynh 203b72d
reindented everything with spaces instead of tabs
MiHHuynh 7dc77a3
finished ES2015 exercises
MiHHuynh 4cdb916
padEnd, flatten
MiHHuynh 069f8f6
flatten and flattenDeep
MiHHuynh c1c102d
zip
MiHHuynh 97f33d1
flattenDeep, unzip
MiHHuynh d3084ba
finished hacker news clone
MiHHuynh 19b05ab
finished lodash exercises and recursion stringifyNumbers
MiHHuynh c39642a
finished call apply bind exercises - ready for review
MiHHuynh 3284548
finished parts 1 and 2 for prototypes exercises - ready for review
MiHHuynh a4e9826
incomplete hack or snooze. Need to work on implementing signup/login …
MiHHuynh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Hacker News Clone</title> | ||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
| <link rel="stylesheet" href="style.css"> | ||
| </head> | ||
| <body> | ||
| <div class="wrapper"> | ||
| <div class="panel panel-default custom-panel"> | ||
| <div class="panel-heading custom-panel"> | ||
| <span class="title">Hack or Snooze</span> | ||
| <span class="submit">submit</span> | <span class="favorites">favorites</span> | ||
| <span class="login">log in / sign up</span> | ||
| </div> | ||
| </div> | ||
| <div class="row login-signup-form"> | ||
| <div class="col-md-3 col-md-offset-6"> | ||
| <form action="submit" class="custom-form login-form"> | ||
| <div class="form-group"> | ||
| <label for="email">email:</label> | ||
| <input type="text" class="form-control" id="login-email"> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="login-pw">password:</label> | ||
| <input type="password" class="form-control" id="url"> | ||
| </div> | ||
| <button class="btn btn-default login-button">log in</button> | ||
| </form> | ||
| </div> | ||
| <div class="col-md-3 col-md-offset-3"> | ||
| <form action="#" class="custom-form signup-form" id="signup-form"> | ||
| <div class="form-group"> | ||
| <label for="email">email:</label> | ||
| <input type="text" class="form-control" id="signup-email"> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="pw">password:</label> | ||
| <input type="password" class="form-control" id="signup-pw"> | ||
| </div> | ||
| <button type="submit" class="btn btn-default signup-button">sign up</button> | ||
| </form> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- <form action="submit" class="custom-form submit-form"> | ||
| <div class="form-group"> | ||
| <label for="title">title:</label> | ||
| <input type="text" class="form-control" id="title"> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="url">url:</label> | ||
| <input type="url" class="form-control" id="url" value="https://"> | ||
| </div> | ||
| <button class="btn btn-default submit-button">submit</button> | ||
| </form> --> | ||
| <ol class="link-items"> | ||
| </ol> | ||
|
|
||
| </div> | ||
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | ||
| <script src="script.js"></script> | ||
| </body> | ||
| </html> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| $(document).ready(function(){ | ||
| var star = "<span class=\"glyphicon glyphicon-star-empty\" aria-hidden=\"true\"></span>"; | ||
| var $linkItemsOl = $(".link-items"); | ||
|
|
||
| $.ajax({ | ||
| method: "GET", | ||
| url: "https://hacker-news.firebaseio.com/v0/topstories.json?" | ||
| }).then(function(topItems){ | ||
| var top20 = topItems.slice(0,20); | ||
| for (let i = 0; i < top20.length; i++) { | ||
| $.ajax({ | ||
| method: "GET", | ||
| dataType: "json", | ||
| url: `https://hacker-news.firebaseio.com/v0/item/${top20[i]}.json?print=pretty` | ||
| }).then(function(item){ | ||
| addItemToList(item.title, item.url); | ||
| console.log(item.title + '\n' + item.url); | ||
| //item.title | ||
| //item.url | ||
| }); | ||
|
|
||
| } | ||
| }); | ||
|
|
||
| function addItemToList(itemTitle, itemUrl) { | ||
| var $newItem = $("<li>", { "class" : "item"}); | ||
| var aTag = ` <a href="${itemUrl}">${itemTitle}</a>`; | ||
| $newItem.html(star + " " + aTag); | ||
| $linkItemsOl.append($newItem); | ||
| console.log(aTag); | ||
| } | ||
|
|
||
| $(".login").on("click", function(e) { | ||
| $(".login-form").toggle(); | ||
| $(".signup-form").toggle(); | ||
| }); | ||
|
|
||
| $("login-signup-form").on("click", "login-button", function(e){ | ||
| e.preventDefault(); | ||
| var email = $("#login-email").val(); | ||
| var pw = $("#login-pw").val(); | ||
| $.ajax({ | ||
| method: "POST", | ||
| url: "https://hn-favorites.herokuapp.com/login", | ||
| //Content-Type: "application/json" | ||
| data: { | ||
| "email" : email, | ||
| "password": pw | ||
| } | ||
| }).then(function(authKey){ | ||
| console.log(authKey); | ||
| }); | ||
| }); | ||
|
|
||
| $("#signup-form").on("submit", function(e){ | ||
| e.preventDefault(); | ||
| var email = $("#signup-email").val(); | ||
| var pw = $("#signup-pw").val(); | ||
| console.log(email + pw); | ||
| $.ajax({ | ||
| method: "POST", | ||
| url: "https://hn-favorites.herokuapp.com/signup", | ||
| data: { | ||
| "email" : email, | ||
| "password": pw | ||
| } | ||
| }).then(function(authKey){ | ||
| console.log(authKey); | ||
| }); | ||
| }); | ||
|
|
||
| // what to do with the authkey? | ||
| // you need it to: | ||
| // GET all favorites | ||
| // DELETE a favorite | ||
|
|
||
| // when you click the log in button | ||
| // post to log in | ||
| // | ||
|
|
||
|
|
||
| // var $submitLink = $(".submit"); | ||
| // var $submitForm = $(".submit-form"); | ||
| // var $submitBtn = $(".submit-button"); | ||
| // var $linkItemsOl = $(".link-items"); | ||
| // var star = "<span class=\"glyphicon glyphicon-star-empty\" aria-hidden=\"true\"></span>"; | ||
| // var $title = $("#title"); | ||
| // var $url = $("#url"); | ||
| // var $favSpan = $(".favorites"); | ||
|
|
||
| // $submitLink.on("click", function(){ | ||
| // $submitForm.toggle(); | ||
| // }); | ||
|
|
||
| // $("body").on("click", ".glyphicon", function(e){ | ||
| // $(e.target).toggleClass("glyphicon-star-empty glyphicon-star"); | ||
| // }); | ||
|
|
||
| // $submitBtn.on("click", function(e){ | ||
| // e.preventDefault(); | ||
| // var title = $("#title").val(); | ||
| // var url = $("#url").val(); | ||
| // var $newItem = $("<li>"); | ||
| // var aTag = ` <a href="${url}">${title}</a>`; | ||
| // $newItem.html(star + " " + aTag); | ||
| // $linkItemsOl.append($newItem); | ||
| // console.log(aTag); | ||
| // $title.val(""); | ||
| // $url.val("https://"); | ||
| // }); | ||
|
|
||
| // $favSpan.on("click", function(e){ | ||
| // var stars = $(".glyphicon"); | ||
| // if ($favSpan.hasClass("favorites")) { | ||
| // for (let i = 0; i < stars.length; i++) { | ||
| // console.log(stars[i]); | ||
| // if ($(stars[i]).hasClass("glyphicon-star-empty")) { | ||
| // $(stars[i]).parent().hide(); | ||
| // } | ||
| // } | ||
| // $favSpan.text("all"); | ||
| // } | ||
| // else if ($favSpan.hasClass("all")) { | ||
| // for (let i = 0; i < stars.length; i++) { | ||
| // console.log(stars[i]); | ||
| // if ($(stars[i]).hasClass("glyphicon-star-empty")) { | ||
| // $(stars[i]).parent().show(); | ||
| // } | ||
| // } | ||
| // $favSpan.text("favorites"); | ||
| // } | ||
| // $favSpan.toggleClass("favorites all"); | ||
| // }); | ||
|
|
||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| .item { | ||
| margin-bottom: 10px; | ||
| } | ||
|
|
||
| .title, .submit, .favorites { | ||
| height: 3em; | ||
| margin: 5px; | ||
| } | ||
|
|
||
| .submit:hover, .favorites:hover, .all:hover, .login:hover, .signup:hover { | ||
| text-decoration: underline; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .login { | ||
| margin-left: 63%; | ||
| } | ||
|
|
||
| .glyphicon:hover { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .title { | ||
| font-size: 1.5em; | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| .wrapper { | ||
| background-color: #f6f6ef; | ||
| width: 80%; | ||
| margin-top: 1em; | ||
| margin-left: auto; | ||
| margin-right: auto; | ||
| color: #828282; | ||
| } | ||
|
|
||
|
|
||
| .panel > .panel-heading, .custom-panel { | ||
| background-image: none; | ||
| background-color: rgb(255, 102, 0); | ||
| color: black; | ||
| border: 1px solid rgb(255, 102, 0); | ||
| } | ||
|
|
||
| /*.custom-form { | ||
| width: 15%; | ||
| margin-left: 68em; | ||
| margin-bottom: 2em; | ||
| display: none; | ||
| }*/ | ||
|
|
||
| a, a:hover { | ||
| color: black; | ||
| } | ||
|
|
||
| .link-items { | ||
| margin-bottom: 50px; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| function sumEvenArguments() { | ||
| var arr = [].slice.call(arguments); | ||
| var sum = 0; | ||
| for (let i = 0; i < arr.length; i++) { | ||
| if (arr[i] % 2 === 0) { | ||
| sum += arr[i]; | ||
| } | ||
| } | ||
| return sum; | ||
| } | ||
|
|
||
| function arrayFrom(arrLikeObj) { | ||
| var arr = [].slice.call(arrLikeObj); | ||
| return arr; | ||
| } | ||
|
|
||
| function invokeMax(fn, maxTimes) { | ||
| var counter = 0; | ||
| return function() { | ||
| if (counter >= maxTimes) { | ||
| return "Maxed Out!"; | ||
| } else { | ||
| counter++; | ||
| return fn.apply(this, arguments); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function guessingGame(num) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job here. |
||
| var answer = Math.floor(Math.random()*10); | ||
| var guesses = 0; | ||
| return function(guess) { | ||
| if (guesses === num) { | ||
| return `No more guesses. The answer was ${answer}.`; | ||
| } | ||
| else { | ||
| guess++; | ||
| if (guess === answer) { | ||
| return "You got it!"; | ||
| } | ||
| else if (guess > answer) { | ||
| return "You're too high!"; | ||
| } | ||
| else if (guess < answer) { | ||
| return "You're too low!"; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,19 +3,28 @@ | |
| Fix the following code: | ||
|
|
||
| ```javascript | ||
| // var obj = { | ||
| // fullName: "Harry Potter", | ||
| // person: { | ||
| // sayHi: function(){ | ||
| // return "This person's name is " + this.fullName | ||
| // } | ||
| // } | ||
| // } | ||
|
|
||
| var obj = { | ||
| fullName: "Harry Potter", | ||
| person: { | ||
| sayHi: function(){ | ||
| return "This person's name is " + this.fullName | ||
| } | ||
| }.apply(obj) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want to use bind here: |
||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - List two examples of "array-like-objects" that we have seen. | ||
| - | ||
| - | ||
| - arguments | ||
| - result of DOM method such as getElementsByTagName | ||
|
|
||
| ### Functions to write: | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if you had learned spread yet, but you can do