Skip to content

did 6 #9

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
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 16 additions & 0 deletions add-eventing/add-eventing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
const addEventing = function (obj) {
obj.on = (eventName, fn) => {
if (events[eventName]) {
events[eventName].push(fn)
} else {
events[eventName] = [fn]
}
}

obj.trigger = (eventName, ...args) => {
events[eventName].forEach(fn => fn(...args))
}

return obj



}

module.exports = addEventing
7 changes: 7 additions & 0 deletions babylonian-method/babylonian.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const squareRoot = (radicand) => {
for (let i = radicand; i >= 1; i--) {
if (i * i == radicand) {
radicand = i;
break;
}
}
return radicand

}

module.exports = squareRoot
40 changes: 39 additions & 1 deletion balanced-parens/balanced-parens.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
const parensAreBalanced = (input) => {
return false
// let stack = [];
// let map = {
// '(': ')',
// '[': ']',
// '{': '}'
// }

// for (let i = 0; i < str.length; i++) {


// if (str[i] === '(' || str[i] === '{' || str[i] === '[' ) {
// stack.push(str[i]);
// }

// else {
// let last = stack.pop();


// if (str[i] !== map[last]) {
// return false
// };
// }
let inputSplt = input.split("");
return !inputSplt.reduce((prevChar, currChar) => {
if (currChar === "(" || currChar === "{" || currChar === "[") {
return ++prevChar;
} else if (currChar === ")" || currChar === "}" || currChar === "]") {
return --prevChar;
}
return prevChar;
}, 0);
}

if (stack.length !== 0) {

return false
};

return true;
}

module.exports = parensAreBalanced
1 change: 1 addition & 0 deletions node_modules/.bin/ignored

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/tape

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions node_modules/@sinonjs/commons/CHANGES.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions node_modules/@sinonjs/commons/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@sinonjs/commons/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions node_modules/@sinonjs/commons/lib/called-in-order.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 121 additions & 0 deletions node_modules/@sinonjs/commons/lib/called-in-order.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions node_modules/@sinonjs/commons/lib/class-name.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading