Skip to content

Completed exercises #18

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 1 commit into
base: main
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions Stephanie-Jones/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
9 changes: 9 additions & 0 deletions Stephanie-Jones/01/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Assignment Ex 01

In this exercise, you can expected to check if a positive number is a multiple 5 or a multiple of 9


Here is a visual of what is expected:

![Ex 01](https://github.com/QualityWorksCG/javascript-and-git-automation-bootcamp/main/media/ex-01.png)

28 changes: 28 additions & 0 deletions Stephanie-Jones/01/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
describe('Exercise 01', () => {
test('01. Check if a positive number is a multiple of 5 or 9', () => {
/**
* You are expected to return a boolean value
*/

function multipleOf5Or9(positiveNumber) {
// Your code here
if (positiveNumber%5==0){
return true;
} else if (positiveNumber%9==0){
return true;
}else{
return false;
}


}

// Test cases
expect(multipleOf5Or9(10)).toBe(true);
expect(multipleOf5Or9(20)).toBe(true);
expect(multipleOf5Or9(21)).toBe(false);
expect(multipleOf5Or9(36)).toBe(true);
expect(multipleOf5Or9(22)).toBe(false);
expect(multipleOf5Or9(23)).toBe(false);
});
});
9 changes: 9 additions & 0 deletions Stephanie-Jones/02/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Assignment Ex 02

Create a new string by taking the last 3 letters of an existing string and adding those letters at the back and the front of the new string.

Bear in mind that the existing string should be more than 3 characters

Here is a visual of what is expected:

![Ex 02](https://github.com/QualityWorksCG/javascript-and-git-automation-bootcamp/main/media/ex-02.png)
32 changes: 32 additions & 0 deletions Stephanie-Jones/02/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe('02', () => {
it('02. Create a new string from any string by taking the last 3 letters of that string and adding it to the front and back.', () => {
/**
* If the length of the string is less than 3, return false.
*
* Remember we discussed splice() method in the previous exercise.
*/

function lastThree(str) {
// Your code here
if (str.length<3){
return false;
} else if(str.length==3){
var word= str;
var output = []
output.push(word,str,word);
return output.join("")
}
else{
var concat= str.slice(2,5)
var newstring = []
newstring.push(concat,str,concat);
return newstring.join("")
}
}

// Test cases
expect(lastThree('hello')).toBe('llohellollo');
expect(lastThree('wor')).toBe('worworwor');
expect(lastThree('qw')).toBe(false);
});
});
8 changes: 8 additions & 0 deletions Stephanie-Jones/03/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Assignment Ex 03

Check between two integers which the difference is 6, the sum of them makes 6 or any of them is 6.


Here is a visual of what is expected:

![Ex 03](https://github.com/QualityWorksCG/javascript-and-git-automation-bootcamp/main/media/03-ex.png)
29 changes: 29 additions & 0 deletions Stephanie-Jones/03/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

describe('03', () => {
it('03. Check if any of two number is 6, if the sum of them makes 6 or if the difference is 6', () => {

function isSix(x, y) {
if(x==6 || y==6){
return true;
} else if(x+y==6){
return true;
}else if( Math.abs(x-y)==6){
return true;
} else{
return false;
}


}

// Test cases
expect(isSix(6, 0)).toBe(true);
expect(isSix(5, 10)).toBe(false);
expect(isSix(0, 6)).toBe(true);
expect(isSix(3, 3)).toBe(true);
expect(isSix(3, 4)).toBe(false);
expect(isSix(3, 9)).toBe(true);
expect(isSix(3, 3)).toBe(true);
expect(isSix(3, 3)).toBe(true);
});
});
7 changes: 7 additions & 0 deletions Stephanie-Jones/04/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Assignment Ex 04

Check if an array of 3 items, contains a 5 or 2

Here is a visual:

![Ex 04](https://github.com/QualityWorksCG/javascript-and-git-automation-bootcamp/main/media/04-ex.png)
25 changes: 25 additions & 0 deletions Stephanie-Jones/04/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe('04', () => {
test('Check if an array of 3 items, contains a 5 or 2', () => {

const arrayIncludes5Or2 = (array) => {
if(array.includes(5)){
return true;
}else if(array.includes(2)){
return true;
}else{
return false;
}


}

// Test cases
expect(arrayIncludes5Or2([1, 2, 3])).toBe(true);
expect(arrayIncludes5Or2([1, 4, 3])).toBe(false);
expect(arrayIncludes5Or2([1, 4, 5])).toBe(true);
expect(arrayIncludes5Or2([1, 4, 6])).toBe(false);
expect(arrayIncludes5Or2([1, 4, 7])).toBe(false);
expect(arrayIncludes5Or2([1, 4, 8])).toBe(false);
expect(arrayIncludes5Or2([1, 4, 9])).toBe(false);
});
});
3 changes: 3 additions & 0 deletions Stephanie-Jones/05/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Assignment Ex 05

Take an array of any length and add all elements to return a sum
21 changes: 21 additions & 0 deletions Stephanie-Jones/05/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
describe('05', () => {
it('Take an array of any length and add all elements to return a sum', () => {


const sum = (array) => {
var total=0;
array.forEach(element => {
total +=element;
});
return total;
}

// Test cases
expect(sum([1, 2, 3])).toBe(6);
expect(sum([1, 4, 3, 50, 10])).toBe(68);
expect(sum([1, 4, 5, 6, 7, 8, 9, 10])).toBe(50);
expect(sum([1, 4, 6, 7, 8, 9, 10])).toBe(45);
expect(sum([1, 4, 7, 8, 9, 10])).toBe(39);
expect(sum([1, 4, 8, 9, 10])).toBe(32);
});
})
29 changes: 29 additions & 0 deletions Stephanie-Jones/06/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
You just got a new Job as a teacher, and you have a bunch of exam paper to mark.

From the following list of papers check if each individual one is submitted, and if so send that paper for marking which is a async function.

```js
const listOfPapers = [
{
subject: "Math",
wasSubmitted: true,
markPaper: () => {

}
},
{
subject: "Geology",
wasSubmitted: true,
markPaper: () => {

}
},
{
subject: "Social Studies",
wasSubmitted: false,
markPaper: () => {

}
},
]
```
Loading