Skip to content

Kimberly stewart assignment #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
wants to merge 3 commits 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 Kimberly-Stewart/.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 Kimberly-Stewart/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://raw.githubusercontent.com/QualityWorksCG/javascript-and-git-automation-bootcamp/main/media/ex-01.png)

24 changes: 24 additions & 0 deletions Kimberly-Stewart/01/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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){
if (positiveNumber % 5 == 0 || 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 Kimberly-Stewart/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://raw.githubusercontent.com/QualityWorksCG/javascript-and-git-automation-bootcamp/main/media/ex-02.png)
25 changes: 25 additions & 0 deletions Kimberly-Stewart/02/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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) {
if (str.length >=3){

const endofstring = str.slice(-3)
return endofstring + str + endofstring
} else {
return false
}

}

// Test cases
expect(lastThree('hello')).toBe('llohellollo');
expect(lastThree('wor')).toBe('worworwor');
expect(lastThree('qw')).toBe(false);
});
});
8 changes: 8 additions & 0 deletions Kimberly-Stewart/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://raw.githubusercontent.com/QualityWorksCG/javascript-and-git-automation-bootcamp/main/media/03-ex.png)
22 changes: 22 additions & 0 deletions Kimberly-Stewart/03/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 || x-y == 6 || y-x == 6 || x+y == 6 ){
return true
}else{
return false
}

}

// Test cases
expect(isSix(6, 0)).toBe(true);
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 Kimberly-Stewart/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://raw.githubusercontent.com/QualityWorksCG/javascript-and-git-automation-bootcamp/main/media/04-ex.png)
23 changes: 23 additions & 0 deletions Kimberly-Stewart/04/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe('04', () => {
test('Check if an array of 3 items, contains a 5 or 2', () => {

const arrayIncludes5Or2 = (array) => {
// Your code here
if (array.includes (5) || array.includes (2)) {
return true
}else{
return false
}

}

//Test cases
expect(arrayIncludes5Or2([1, 2, 3]))
expect(arrayIncludes5Or2([1, 4, 3]))
expect(arrayIncludes5Or2([1, 4, 5]))
expect(arrayIncludes5Or2([1, 4, 6]))
expect(arrayIncludes5Or2([1, 4, 7]))
expect(arrayIncludes5Or2([1, 4, 8]))
expect(arrayIncludes5Or2([1, 4, 9]))
});
});
3 changes: 3 additions & 0 deletions Kimberly-Stewart/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
22 changes: 22 additions & 0 deletions Kimberly-Stewart/05/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe('05', () => {
it('Take an array of any length and add all elements to return a sum', () => {


const sum = (array) => {
// Your code here
let sum = 0
for(let i = 0; i <array.length;i++){
sum += array[i]
}
return sum
}

// 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 Kimberly-Stewart/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: () => {

}
},
]
```
59 changes: 59 additions & 0 deletions Kimberly-Stewart/06/exercise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
describe('06', () => {

// Tip: Use setTimeout to delay the execution of marking

const listOfPapers = [
{
subject: "Maths",
wasSubmitted: true,
markPaper: () => {
const promise = new Promise ((resolve, reject) =>{
setTimeout(() => {
resolve("Math paper marked")
}, 2000);
})
}
},
{
subject: "Geology",
wasSubmitted: true,
markPaper: () => {
const promise = new Promise ((resolve, reject) =>{
setTimeout(() => {
resolve("Geology paper marked")
}, 2000);
})
}
},

{
subject: "Social Studies",
wasSubmitted: false,
markPaper: () => {
const promise = new Promise ((resolve, reject) =>{
setTimeout(() => {
resolve("SOcial Studies paper marked")
}, 2000);
})
}
},
]

it('Check if a paper was submitted, and if yes, wait for it to be marked', async () => {
const spyOnLog = vi.spyOn(console, 'log');

// Your code here
for await (const paper of listOfPapers){
if (paper.wasSubmitted === true){
return paper.markPaper()
}
}

expect(spyOnLog).toHaveBeenCalledWith("Maths paper marked");
expect(spyOnLog).toHaveBeenCalledWith("Geology paper marked");
expect(spyOnLog).not.toHaveBeenCalledWith("Social Studies paper marked");
expect(listOfPapers[0].markPaper()).toBeInstanceOf(Promise);
expect(listOfPapers[1].markPaper()).toBeInstanceOf(Promise);
expect(listOfPapers[2].markPaper()).toBeInstanceOf(Promise);
});
});
5 changes: 5 additions & 0 deletions Kimberly-Stewart/07/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
An Array has lots of methods that you can use. In the bootcamp you learn about
iterating an array using for keyword, but you can iterate an array with an array method


Using the "forEach" array method, print the current element
Loading