Skip to content

Commit 1a1fb06

Browse files
Merge pull request #5 from james-gates-0212/4-calculate-the-sum-of-the-numbers-in-an-array
4 calculate the sum of the numbers in a nested array
2 parents c79c37b + 234b238 commit 1a1fb06

File tree

27 files changed

+1369
-161
lines changed

27 files changed

+1369
-161
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

β€Ž.husky/commit-msgβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn commitlint ${1}

β€Ž.husky/pre-commitβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# yarn test
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"singleQuote": true,
33
"arrowParens": "always",
4-
"printWidth": 60,
4+
"printWidth": 120,
55
"trailingComma": "all"
66
}

β€Ž.vscode/settings.jsonβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"typescript.preferences.importModuleSpecifier": "non-relative",
44
"workbench.colorCustomizations": {
55
"titleBar.activeForeground": "#000",
6-
"titleBar.inactiveForeground": "#000000CC",
7-
"titleBar.activeBackground": "#ffc600",
8-
"titleBar.inactiveBackground": "#ffc600CC"
6+
"titleBar.inactiveForeground": "#000000cc",
7+
"titleBar.activeBackground": "#fc9d26",
8+
"titleBar.inactiveBackground": "#fc9d26cc"
99
},
1010
"editor.defaultFormatter": "esbenp.prettier-vscode",
1111
"editor.formatOnSave": true,

β€ŽCODE_OF_CONDUCT.mdβ€Ž

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
- Demonstrating empathy and kindness toward other people
21+
- Being respectful of differing opinions, viewpoints, and experiences
22+
- Giving and gracefully accepting constructive feedback
23+
- Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
- Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
- The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
- Trolling, insulting or derogatory comments, and personal or political attacks
33+
- Public or private harassment
34+
- Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
- Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
james.gates.0212@gmail.com.
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

β€ŽCONTRIBUTING.mdβ€Ž

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Contributing
2+
3+
First off, thanks for taking the time to contribute! ❀️
4+
5+
When contributing to this repository, please first discuss the change you wish to make via issue,
6+
email, or any other method with the owners of this repository before making a change.
7+
8+
Please note we have a code of conduct, please follow it in all your interactions with the project.
9+
10+
## Pull Request Process
11+
12+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
13+
build.
14+
2. Update the README.md with details of changes to the interface, this includes new environment
15+
variables, exposed ports, useful file locations and container parameters.
16+
3. Increase the version numbers in any examples files and the README.md to the new version that this
17+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
18+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
19+
do not have permission to do that, you may request the second reviewer to merge it for you.
20+
21+
## Code of Conduct
22+
23+
### Our Pledge
24+
25+
In the interest of fostering an open and welcoming environment, we as
26+
contributors and maintainers pledge to making participation in our project and
27+
our community a harassment-free experience for everyone, regardless of age, body
28+
size, disability, ethnicity, gender identity and expression, level of experience,
29+
nationality, personal appearance, race, religion, or sexual identity and
30+
orientation.
31+
32+
### Our Standards
33+
34+
Examples of behavior that contributes to creating a positive environment
35+
include:
36+
37+
- Using welcoming and inclusive language
38+
- Being respectful of differing viewpoints and experiences
39+
- Gracefully accepting constructive criticism
40+
- Focusing on what is best for the community
41+
- Showing empathy towards other community members
42+
43+
Examples of unacceptable behavior by participants include:
44+
45+
- The use of sexualized language or imagery and unwelcome sexual attention or
46+
advances
47+
- Trolling, insulting/derogatory comments, and personal or political attacks
48+
- Public or private harassment
49+
- Publishing others' private information, such as a physical or electronic
50+
address, without explicit permission
51+
- Other conduct which could reasonably be considered inappropriate in a
52+
professional setting
53+
54+
### Our Responsibilities
55+
56+
Project maintainers are responsible for clarifying the standards of acceptable
57+
behavior and are expected to take appropriate and fair corrective action in
58+
response to any instances of unacceptable behavior.
59+
60+
Project maintainers have the right and responsibility to remove, edit, or
61+
reject comments, commits, code, wiki edits, issues, and other contributions
62+
that are not aligned to this Code of Conduct, or to ban temporarily or
63+
permanently any contributor for other behaviors that they deem inappropriate,
64+
threatening, offensive, or harmful.
65+
66+
### Scope
67+
68+
This Code of Conduct applies both within project spaces and in public spaces
69+
when an individual is representing the project or its community. Examples of
70+
representing a project or community include using an official project e-mail
71+
address, posting via an official social media account, or acting as an appointed
72+
representative at an online or offline event. Representation of a project may be
73+
further defined and clarified by project maintainers.
74+
75+
### Enforcement
76+
77+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
78+
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
79+
complaints will be reviewed and investigated and will result in a response that
80+
is deemed necessary and appropriate to the circumstances. The project team is
81+
obligated to maintain confidentiality with regard to the reporter of an incident.
82+
Further details of specific enforcement policies may be posted separately.
83+
84+
Project maintainers who do not follow or enforce the Code of Conduct in good
85+
faith may face temporary or permanent repercussions as determined by other
86+
members of the project's leadership.
87+
88+
### Attribution
89+
90+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
91+
available at [http://contributor-covenant.org/version/1/4][version]
92+
93+
[homepage]: http://contributor-covenant.org
94+
[version]: http://contributor-covenant.org/version/1/4/

β€ŽLICENSEβ€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 James Gates
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

β€ŽREADME.mdβ€Ž

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# JavaScript Assessments
1+
# πŸ““JavaScript Assessments
22

3+
- [Calculate the sum of the numbers in a nested array](calculate-the-sum-of-the-numbers-in-a-nested-array)
34
- [Convert string to group](convert-string-to-group)
45
- [Delete Overlapping Intervals](delete-overlapping-intervals)
56
- [Filling all the missed angle brackets](filling-all-the-missed-angle-brackets)
@@ -12,3 +13,91 @@
1213
- [Replacing with the cipher letters](replacing-with-the-cipher-letters)
1314
- [Throttle Queue](throttle-queue)
1415
- [Validating a maze path](validating-a-maze-path)
16+
17+
## πŸ“Environment
18+
19+
- node 18.x or later
20+
- yarn 1.x or later
21+
- npm 8.x or later
22+
23+
## 🚧Install npm packages
24+
25+
```bash
26+
npm i -g yarn
27+
yarn
28+
```
29+
30+
## βœ…Lint
31+
32+
```bash
33+
yarn lint
34+
```
35+
36+
## ❀️Prettier
37+
38+
```bash
39+
prettier --write ./
40+
```
41+
42+
```bash
43+
# if you couldn't run above command line, it would work after run this...
44+
npm i -g prettier
45+
```
46+
47+
## 🐞Git commit
48+
49+
Please use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for your commits.
50+
51+
e.g.
52+
53+
```commit
54+
<type>[scope]: <subject>
55+
[body]
56+
[footer]
57+
```
58+
59+
### ♻️Types
60+
61+
`type` should be one of belows.
62+
63+
```bash
64+
add
65+
adopt
66+
build
67+
chore
68+
docs
69+
feat
70+
fix
71+
refactor
72+
remove
73+
style
74+
```
75+
76+
### πŸ““Subject
77+
78+
`subject` should include one of emojis as belows.
79+
80+
♻️
81+
⚑️
82+
βœ…
83+
✏️
84+
✨
85+
❀️
86+
⬆️
87+
⬇️
88+
⭐️
89+
🌈
90+
🎁
91+
πŸŽ‰
92+
πŸ†
93+
🐞
94+
πŸ‘Œ
95+
πŸ““
96+
πŸ“
97+
πŸ“¦
98+
πŸ”€
99+
πŸ”–
100+
πŸš€
101+
🚧
102+
🚨
103+
πŸ› οΈ
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Calculate the sum of the numbers in a nested array
2+
3+
You need to calculate the sum of the numbers in an array. However, the array contains nested arrays, whose numbers you must also count. These nested arrays may also have further arrays recursively nested in them, and so on. You do not know how deep the nesting continues. If the list is empty, return zero.
4+
5+
The arrays may also contain data that is not of the type number(`string`, `BigInt`, `object`, etc), which you should ignore.
6+
7+
## Examples
8+
9+
```javascript
10+
nestedSum([1, 2, [3, [4], 5, '6'], 6]); // should == 21
11+
nestedSum([2, [[[[[3]]]]]]); // should == 5
12+
nestedSum([]); // should == 0
13+
```
14+
15+
## Execute
16+
17+
```bash
18+
node solution.js
19+
```

0 commit comments

Comments
Β (0)