From d9855db4c1f9dd9e7396af6ccb0e1d7291f047a2 Mon Sep 17 00:00:00 2001 From: Priya Date: Tue, 14 Mar 2023 18:04:15 +0000 Subject: [PATCH] completed easy(random, sum) and attempted medium (pig latin --- jasminedemo/package.json | 0 src/easy/3or5/plain.md | 9 +++++++++ src/easy/3or5/pseudo.md | 5 +++++ src/easy/digitCount/plain.md | 13 +++++++++++++ src/easy/digitCount/pseudo.md | 14 ++++++++++++++ src/easy/factorial/plain.md | 7 +++++++ src/easy/factorial/pseudo.md | 9 +++++++++ src/easy/makeSentence/plain.md | 4 ++++ src/easy/makeSentence/problem.md | 1 + src/easy/makeSentence/pseudo.md | 1 + src/easy/random/plain.md | 8 ++++++++ src/easy/random/pseudo.md | 7 +++++++ src/easy/random/solution.js | 16 ++++++++++++++++ src/easy/sum/plain.md | 8 ++++++++ src/easy/sum/pseudo.md | 10 ++++++++++ src/easy/sum/solution.js | 16 ++++++++++++++++ src/medium/pigLatin/solution.js | 27 +++++++++++++++++++++++++++ 17 files changed, 155 insertions(+) create mode 100644 jasminedemo/package.json diff --git a/jasminedemo/package.json b/jasminedemo/package.json new file mode 100644 index 0000000..e69de29 diff --git a/src/easy/3or5/plain.md b/src/easy/3or5/plain.md index 73370f1..1cab5b8 100644 --- a/src/easy/3or5/plain.md +++ b/src/easy/3or5/plain.md @@ -1 +1,10 @@ # Plain English Solution +If you list all the natural numbers below 10 that are multiples of 3 or 5, you'll get 3, 5, 6 and 9. The sum of these multiples is 23. + +Find the sum of all the multiples of 3 or 5 below 1000. + +1) create a list from 1 - 1000 +2) Go through each number so we are able to check if they are a multiple of 3 and 5. +3) When a number is a multiple of 3 and 5, save these values +4) create a sum of these values +5) return the total value \ No newline at end of file diff --git a/src/easy/3or5/pseudo.md b/src/easy/3or5/pseudo.md index 520841f..e5ff70c 100644 --- a/src/easy/3or5/pseudo.md +++ b/src/easy/3or5/pseudo.md @@ -1 +1,6 @@ # Pseudo Code Solution +1) create const variable 'find numbers that are multiples of 3 and 5;' +2) create another const variable for loops +3) create a loop where the condition is less that 1,000 and adds one - use the push function (adds elements to the end) +4) Use the modulo % 3 and % 5 in order to get the multiples +5) get the result \ No newline at end of file diff --git a/src/easy/digitCount/plain.md b/src/easy/digitCount/plain.md index 73370f1..3aa932f 100644 --- a/src/easy/digitCount/plain.md +++ b/src/easy/digitCount/plain.md @@ -1 +1,14 @@ # Plain English Solution +# Digit Count + +Given a number, count the number of digits. For example: + +```text +318 = 3 +92563 = 5 +4666 = 4 +314890 = 6 +``` + +1) create a list - all numnbers above 0 +2) use count formula so any number will count the number of digits \ No newline at end of file diff --git a/src/easy/digitCount/pseudo.md b/src/easy/digitCount/pseudo.md index 520841f..8f3202f 100644 --- a/src/easy/digitCount/pseudo.md +++ b/src/easy/digitCount/pseudo.md @@ -1 +1,15 @@ + # Pseudo Code Solution + + +Given a number, count the number of digits. For example: + +```text +318 = 3 +92563 = 5 +4666 = 4 +314890 = 6 +``` +1) create two const, one to enter any number and two, so the num formula can feed through +2) the second const - use function called count which equals 0 +3) use an if statement to return digits \ No newline at end of file diff --git a/src/easy/factorial/plain.md b/src/easy/factorial/plain.md index 73370f1..1d4afba 100644 --- a/src/easy/factorial/plain.md +++ b/src/easy/factorial/plain.md @@ -1 +1,8 @@ # Plain English Solution +Find the product of all positive integers less than or equal to any given number. This is known as the _factorial_ (denoted by _!_): + +`5! = 5 x 4 x 3 x 2 x 1 = 120` + +1) create function +2) create a list of numbers above 1 by creating a loop +3) each number entered in the console log, for example, 8, will times all numbers from 1-8 together \ No newline at end of file diff --git a/src/easy/factorial/pseudo.md b/src/easy/factorial/pseudo.md index 520841f..da79f7f 100644 --- a/src/easy/factorial/pseudo.md +++ b/src/easy/factorial/pseudo.md @@ -1 +1,10 @@ # Pseudo Code Solution +Find the product of all positive integers less than or equal to any given number. This is known as the _factorial_ (denoted by _!_): + +`5! = 5 x 4 x 3 x 2 x 1 = 120` + + 1) create a function called factorial, enter a paramete + 2) create a for loop, which starts from 1, and allocate a condition to find numbers above 1 + 3) assign const with operation of multiplication + 4) create a return, returning the const + 5) console.log \ No newline at end of file diff --git a/src/easy/makeSentence/plain.md b/src/easy/makeSentence/plain.md index 73370f1..5dd5e24 100644 --- a/src/easy/makeSentence/plain.md +++ b/src/easy/makeSentence/plain.md @@ -1 +1,5 @@ # Plain English Solution +Given a sentence, capitalise the first letter and add a full stop to the end. However, if the sentence already ends with some form of puncutation, leave it as is. + +1) create an array - allocate a sentence inside the array +2) use the unshift function that capitalises the first letter \ No newline at end of file diff --git a/src/easy/makeSentence/problem.md b/src/easy/makeSentence/problem.md index e701676..6a5bb2d 100644 --- a/src/easy/makeSentence/problem.md +++ b/src/easy/makeSentence/problem.md @@ -1,3 +1,4 @@ # Make Sentence Given a sentence, capitalise the first letter and add a full stop to the end. However, if the sentence already ends with some form of puncutation, leave it as is. + diff --git a/src/easy/makeSentence/pseudo.md b/src/easy/makeSentence/pseudo.md index 520841f..6435a36 100644 --- a/src/easy/makeSentence/pseudo.md +++ b/src/easy/makeSentence/pseudo.md @@ -1 +1,2 @@ # Pseudo Code Solution +Given a sentence, capitalise the first letter and add a full stop to the end. However, if the sentence already ends with some form of puncutation, leave it as is. diff --git a/src/easy/random/plain.md b/src/easy/random/plain.md index 73370f1..6abbb5b 100644 --- a/src/easy/random/plain.md +++ b/src/easy/random/plain.md @@ -1 +1,9 @@ # Plain English Solution +Create your own method for generating a random number between two other numbers. + +It is common to use _time_ as a means of generating a random number, but there are other ways, too - can you find one? + + +1) choose two random numbers +2) create a function +3) create a return that generates the random number \ No newline at end of file diff --git a/src/easy/random/pseudo.md b/src/easy/random/pseudo.md index 520841f..e32b8a3 100644 --- a/src/easy/random/pseudo.md +++ b/src/easy/random/pseudo.md @@ -1 +1,8 @@ # Pseudo Code Solution +Create your own method for generating a random number between two other numbers. + +It is common to use _time_ as a means of generating a random number, but there are other ways, too - can you find one? + +1) choose two random numbers +2) create a function +3) create a return that generates the random number \ No newline at end of file diff --git a/src/easy/random/solution.js b/src/easy/random/solution.js index e69de29..3d0034a 100644 --- a/src/easy/random/solution.js +++ b/src/easy/random/solution.js @@ -0,0 +1,16 @@ +// //# Pseudo Code Solution +// Create your own method for generating a random number between two other numbers. + +// It is common to use _time_ as a means of generating a random number, but there are other ways, too - can you find one? + +// 1) choose two random numbers +// 2) create a function +// 3) create a return that generates the random number + +let num = 0 +function randomNum (){ + + return num = Math.floor(Math.random()*41); +} + +console.log(randomNum()) \ No newline at end of file diff --git a/src/easy/sum/plain.md b/src/easy/sum/plain.md index 73370f1..a86d22c 100644 --- a/src/easy/sum/plain.md +++ b/src/easy/sum/plain.md @@ -1 +1,9 @@ # Plain English Solution +Sum the numbers from 1 to 100. + +For example, to sum the numbers from 1 to 5, you'd have: + +1 + 2 + 3 + 4 + 5 = 15 + +1) create a list from 1 to 100 +2) sum up the numbers from 1 to 100 \ No newline at end of file diff --git a/src/easy/sum/pseudo.md b/src/easy/sum/pseudo.md index 520841f..5f8517a 100644 --- a/src/easy/sum/pseudo.md +++ b/src/easy/sum/pseudo.md @@ -1 +1,11 @@ # Pseudo Code Solution +Sum the numbers from 1 to 100. + +For example, to sum the numbers from 1 to 5, you'd have: + +1 + 2 + 3 + 4 + 5 = 15 + + +1) create a const variable 'numbers from 1-100' +2) create a loop, where the condition is less than 100 and adds 1 each time +3) create a return \ No newline at end of file diff --git a/src/easy/sum/solution.js b/src/easy/sum/solution.js index e69de29..e7de293 100644 --- a/src/easy/sum/solution.js +++ b/src/easy/sum/solution.js @@ -0,0 +1,16 @@ +// 1) create a const variable 'numbers from 1-100' +// 2) create a loop, where the condition is less than 100 and adds 1 each time +// 3) create a return + +let sumOfNums = 0 + +function num () { + + +for (let i = 1; i <= 100; i++) { +sumOfNums += i +} + +return sumOfNums +} +console.log(num()) \ No newline at end of file diff --git a/src/medium/pigLatin/solution.js b/src/medium/pigLatin/solution.js index e69de29..7ba2b70 100644 --- a/src/medium/pigLatin/solution.js +++ b/src/medium/pigLatin/solution.js @@ -0,0 +1,27 @@ +// # Pig Latin + +// Translate some text to Pig Latin and vice versa. + +// English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. Therefore, "The quick brown fox" becomes "Hetay uickqay rownbay oxfay". + +// var arr = [1, 2, 6, 3, 4, 5]; +// arr.push(arr.splice(2,4), 1)[0]); +// console.log(arr); // [1, 2, 3, 4, 5, 6] + +// "hello world" +// "ellohay orldway" + +//Step 1 "hello world" +//split > [ "hello", "world" +// Step 2 Hello: H shifted then pushed to the end +//step 3 push AY to the end of the ELLOH + +var a = ["h","ello"] + + a.push(a.shift()); + a.push('ay'); + console.log(a); // [1,2,3,4,5] + + + + \ No newline at end of file