-
Notifications
You must be signed in to change notification settings - Fork 82
testing_exercise #32
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
ryoung18
wants to merge
16
commits into
rithmschool:master
Choose a base branch
from
ryoung18: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
testing_exercise #32
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ffa0122
first commit test exercises
ryoung18 fde390a
refactor testing.js
ryoung18 b0ea9a4
add a condition to check for number represented as string '1'
ryoung18 c9b67b9
complete up to binarySearch
ryoung18 825f7bf
add lodash - completed
ryoung18 41299c1
fix tab issues in lodash exercise
ryoung18 8d3a05b
trying to fix tab space issues
ryoung18 3992eaa
fix lodash - CloneDeep removed return
ryoung18 706e905
recursion exercise ready for review
ryoung18 e9c5eff
es2015.js ready for review
ryoung18 2224ccc
add index.js canvas project. Ready for review
ryoung18 25b39a9
add missing canvas files, tictoe incmp, proto exercise, callapplybind
ryoung18 87857ce
add script_ajax
ryoung18 8e2c705
able to login and get favorites
ryoung18 41d1ac6
ajax assignment completed, pls review.
ryoung18 a9ce91c
refactor ajax exercise
ryoung18 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
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,36 +1,94 @@ | ||
| window.addEventListener("load", function() { | ||
| var canvas = document.getElementById("shapes-game"), | ||
| height = canvas.scrollHeight, | ||
| width = canvas.scrollWidth, | ||
| gameOn = false, | ||
| expectedKey = undefined, | ||
| ctx = canvas.getContext('2d'), | ||
| // white triangle = up, red square = down, | ||
| // red triangle = left, white square = right | ||
| expectedKeysMap = {white0: 38, red1: 40, red0: 37, white1: 39}, | ||
| timerSpan = document.getElementById("time-remaining"), | ||
| scoreSpan = document.getElementById("score-val"), | ||
| seconds = 3, | ||
| intervalId; | ||
|
|
||
| canvas.width = width; | ||
| canvas.height = height; | ||
|
|
||
| function clear(ctx, width, heigt) { | ||
| drawGameStartText() | ||
|
|
||
| function clear() { | ||
| ctx.clearRect(0, 0, canvas.width, canvas.height); | ||
| } | ||
|
|
||
| function drawRandomShape(ctx, width, height) { | ||
| function drawRandomShape() { | ||
| var randomShape = ['white0', 'red1', 'red0', 'white1'][Math.floor(Math.random()*4)], | ||
| x = Math.floor(Math.random()*(width-100)), | ||
| y = Math.floor(Math.random()*(height-100)); | ||
| ctx.fillStyle = randomShape.slice(0, -1); | ||
|
|
||
| clear() | ||
|
|
||
| function square(){ | ||
| ctx.fillRect(x,y,100,100); | ||
| } | ||
|
|
||
| function triangle(){ | ||
| ctx.beginPath(); | ||
| ctx.moveTo(x,y); | ||
| ctx.lineTo(100+x, 100+y); | ||
| ctx.lineTo(x, 100+y); | ||
| ctx.fill(); | ||
| ctx.closePath(); | ||
| } | ||
|
|
||
| if(+randomShape[randomShape.length-1] === 1){ | ||
| square() | ||
| } else { | ||
| triangle() | ||
| } | ||
| expectedKey = randomShape; | ||
| } | ||
|
|
||
| function drawGameStartText(ctx, width, height, score) { | ||
|
|
||
| function drawGameStartText() { | ||
| clear() | ||
| ctx.font = '30px serif'; | ||
| ctx.fillStyle = 'white'; | ||
| ctx.fillText('Press the space bar to start a new game', 150, 350); | ||
| } | ||
|
|
||
| function restartGame(ctx, width, height) { | ||
| function restartGame() { | ||
| timerSpan.innerText = 30; | ||
| scoreSpan.innerText = 0; | ||
| gameOn = false; | ||
|
|
||
| drawGameStartText() | ||
| } | ||
|
|
||
| var canvas = document.getElementById("shapes-game"), | ||
| height = canvas.scrollHeight, | ||
| width = canvas.scrollWidth, | ||
| gameOn = false, | ||
| expectedKey = undefined, | ||
| ctx = canvas.getContext('2d'), | ||
| // white triangle = up, red square = down, | ||
| // red triangle = left, white square = right | ||
| expectedKeysMap = {white0: 38, red1: 40, red0: 37, white1: 39}, | ||
| timerSpan = document.getElementById("time-remaining"), | ||
| scoreSpan = document.getElementById("score-val"), | ||
| seconds = 3, | ||
| intervalId; | ||
| document.addEventListener("keyup", function(e) { | ||
| if(gameOn){ | ||
| if(e.keyCode === expectedKeysMap[expectedKey]){ | ||
| scoreSpan.innerText = +scoreSpan.innerText + 1; | ||
| } else { | ||
| scoreSpan.innerText = +scoreSpan.innerText - 1; | ||
| } | ||
| drawRandomShape() | ||
| } | ||
|
|
||
| canvas.width = width; | ||
| canvas.height = height; | ||
| if(!gameOn && e.keyCode === 32){ | ||
| gameOn = true; | ||
| var timerId = setInterval(function(){ | ||
| timerSpan.innerText = +timerSpan.innerText - 1; | ||
| },1000); | ||
|
|
||
| document.addEventListener("keyup", function() { | ||
|
|
||
| setTimeout(function(){ | ||
| clearTimeout(timerId); | ||
| restartGame(); | ||
| },31000); | ||
| } | ||
| }); | ||
|
|
||
| }); | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,75 @@ | ||
| // ## ES2015 Exercise | ||
|
|
||
| // Convert the following es5 code blocks into es2015 code: | ||
|
|
||
| // javascript | ||
| var person = { | ||
| fullName: "Harry Potter", | ||
| sayHi: function (){ | ||
| setTimeout(()=>{ | ||
| console.log(`Your name is ${this.fullName}`) | ||
| },1000) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // javascript | ||
| var name = "Josie" | ||
| // console.log(`When ${name} comes home, so good`) | ||
|
|
||
|
|
||
| // javascript | ||
| // const DO_NOT_CHANGE = 42; | ||
| // DO_NOT_CHANGE = 50; // stop me from doing this! | ||
|
|
||
|
|
||
| // javascript | ||
| var arr = [1,2] | ||
| // var temp = arr[0] | ||
| // arr[0] = arr[1] | ||
| // arr[1] = temp | ||
| var [a,b] = arr, | ||
| arr = [b,a]; | ||
|
|
||
| console.log(arr) | ||
|
|
||
|
|
||
| // javascript | ||
| function double(arr){ | ||
| return arr.map(val => val*2); | ||
| } | ||
|
|
||
| // javascript | ||
| var obj = { | ||
| numbers: { | ||
| a: 1, | ||
| b: 2 | ||
| } | ||
| } | ||
|
|
||
| // var a = obj.numbers.a; | ||
| // var b = obj.numbers.b; | ||
|
|
||
| var {a, b} = obj.numbers; | ||
|
|
||
| // javascript | ||
| function add(a=10,b=10){ | ||
| return a+b | ||
| } | ||
|
|
||
|
|
||
| // Research the following functions - what do they do? | ||
|
|
||
| // `Array.from` - | ||
| // creates a new Array instance from an array-like or iterable object | ||
| // for strings, split('') is similar to this. What is the difference? | ||
|
|
||
| // `Object.assign` - | ||
| //merge and/or clone objects | ||
|
|
||
| // `Array.includes` - | ||
| //Checks to see if an element is in an array. | ||
|
|
||
| // `String.startsWith` - | ||
| //Checks to see if the beginning characters starts with a specific string. | ||
|
|
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.
There is a bug where my score gets decreased when I press a space bar. It might be related to this code