From a52476c497addafaa60549df43b420c7a0d73c6f Mon Sep 17 00:00:00 2001 From: satya Date: Mon, 25 Jul 2022 17:10:55 +0530 Subject: [PATCH] day-7 partially completed --- solutions/day-5/Countries level2.js | 14 +++++ solutions/day-5/level1.js | 73 +++++++++++++++++++++++++++ solutions/day-5/level3.js | 0 solutions/day-5/main level2.js | 3 ++ solutions/day-5/tempCodeRunnerFile.js | 1 + solutions/day-5/web_techs.js | 9 ++++ solutions/day-7/level1.js | 71 ++++++++++++++++++++++++++ solutions/day-7/level2.js | 49 ++++++++++++++++++ solutions/day-7/level3.js | 0 solutions/day-7/tempCodeRunnerFile.js | 1 + 10 files changed, 221 insertions(+) create mode 100644 solutions/day-5/Countries level2.js create mode 100644 solutions/day-5/level1.js create mode 100644 solutions/day-5/level3.js create mode 100644 solutions/day-5/main level2.js create mode 100644 solutions/day-5/tempCodeRunnerFile.js create mode 100644 solutions/day-5/web_techs.js create mode 100644 solutions/day-7/level1.js create mode 100644 solutions/day-7/level2.js create mode 100644 solutions/day-7/level3.js create mode 100644 solutions/day-7/tempCodeRunnerFile.js diff --git a/solutions/day-5/Countries level2.js b/solutions/day-5/Countries level2.js new file mode 100644 index 0000000..0a1280d --- /dev/null +++ b/solutions/day-5/Countries level2.js @@ -0,0 +1,14 @@ +export default Countries = [ + 'Albania', + 'Bolivia', + 'Canada', + 'Denmark', + 'Ethiopia', + 'Finland', + 'Germany', + 'Hungary', + 'Ireland', + 'Japan', + 'Kenya' +] + diff --git a/solutions/day-5/level1.js b/solutions/day-5/level1.js new file mode 100644 index 0000000..81ba9a6 --- /dev/null +++ b/solutions/day-5/level1.js @@ -0,0 +1,73 @@ +// 1.question +let emt = []; +// 2.question +let five = [1, 2, 3, 4, 5]; +// 3.question +console.log(five.length); +// 4.question +let f = 0, l = five.length - 1, mid = (f + l) / 2; +console.log(five[f], five[l], five[mid]); +// 5.question +let mixedDataTypes = [ + 1, + 'satya', + false, + 20, + null +]; +// 6.question +let itCompanies = [ + 'Facebook', + 'Google', + 'Microsoft', + 'Apple', + 'IBM', + 'Oracle', + 'Amazon' +]; +// 7.question +console.log(itCompanies); +// 8.question +console.log(itCompanies.length); +// 9.question +l = itCompanies.length - 1; +console.log(itCompanies[f], itCompanies[l], itCompanies[mid]); +// 10.question +itCompanies.forEach((company) => console.log(company)); +// 11.question +itCompanies.forEach((company) => console.log(company.toUpperCase())); +// 12.question +console.log(itCompanies.toString()); +// 13.question +(itCompanies.includes('Facebook')) ? console.log(itCompanies[itCompanies.indexOf('Facebook')]) : console.log('Not found');; +// 14.question +// itCompanies.map((c) => { +// let count = 0; +// let i = c.split(','); +// i.map((e) => { +// console.log(e); +// if (e.split(',') == 'o') { count++; } +// }) +// if (count > 1) { +// // console.log(c); +// } +// // console.log(c); +// }); +// 15.question +itCompanies.sort(); +// 16.question +itCompanies.reverse(); +// 17.question +itCompanies.slice(0, 2); +// 18.question +itCompanies.slice(l - 4, l - 1); +// 19.question +itCompanies.slice(mid, mid + 1); +// 20.question +itCompanies.shift(); +// 21.question +itCompanies.splice(mid, 1, 0); +// 22.question +itCompanies.pop(); +// 23.question +itCompanies.slice(0); diff --git a/solutions/day-5/level3.js b/solutions/day-5/level3.js new file mode 100644 index 0000000..e69de29 diff --git a/solutions/day-5/main level2.js b/solutions/day-5/main level2.js new file mode 100644 index 0000000..2aa6394 --- /dev/null +++ b/solutions/day-5/main level2.js @@ -0,0 +1,3 @@ +import web_techs from "./web_techs"; + +console.log(web_techs); \ No newline at end of file diff --git a/solutions/day-5/tempCodeRunnerFile.js b/solutions/day-5/tempCodeRunnerFile.js new file mode 100644 index 0000000..1a2d31e --- /dev/null +++ b/solutions/day-5/tempCodeRunnerFile.js @@ -0,0 +1 @@ +console.log(i) \ No newline at end of file diff --git a/solutions/day-5/web_techs.js b/solutions/day-5/web_techs.js new file mode 100644 index 0000000..9262a96 --- /dev/null +++ b/solutions/day-5/web_techs.js @@ -0,0 +1,9 @@ +export default [ + 'HTML', + 'CSS', + 'JavaScript', + 'React', + 'Redux', + 'Node', + 'MongoDB' +] \ No newline at end of file diff --git a/solutions/day-7/level1.js b/solutions/day-7/level1.js new file mode 100644 index 0000000..c189859 --- /dev/null +++ b/solutions/day-7/level1.js @@ -0,0 +1,71 @@ +// 1.question +function fullName() { + console.log(`Satya surendra`); +} +fullName(); +// 2.question +function fullName(fullName,lastName) { + return fullName + ' ' + lastName; +} +console.log(fullName('satya', 'surendra')); + +// 3.question +function addNumbers(a, b) { + return a + b; +} +console.log(addNumbers(1, 2)); +// 4.question +function areaOfRectangle(l,b) { + return l * b; +} +// 5.question +function perimeterOfRectangle(l, b) { + return 2(l + b); +} +// 6.question +function volumeOfRectPrism(l, b, h) { + return l * b * h; +} +// 7.question +function areaOfCircle(r) { + return 3.14 * r * r; +} +// 8.question +function circumOfCircle(r) { + return 2 * 3.14 * r; +} +// 9.question +function density(mass, volume) { + return mass / volume; +} +// 10.question +function speed(d, t) { + return d / t; +} +// 11.question +function weight(mass,gravity) { + return mass * gravity; +} +// 12.question +function convertCelsiusToFahrenheit(c) { + return (c * 9 / 5) + 32; +} +// 13.question +function IBM(weight, height) { + let ibm = weight / Math.pow(height, 2); + if (ibm < 18.5) { + console.log('Underweight'); + } else if (ibm >= 18.5 && ibm < 24.9) { + console.log('Normal weight'); + } else if (ibm >= 25 && ibm < 29.9) { + console.log('Overweight'); + } else { + console.log(`Obese`); + } +} +// 14.question + +// 15.question +function findMax(a, b, c) { + return Math.max(a, b, c); +} diff --git a/solutions/day-7/level2.js b/solutions/day-7/level2.js new file mode 100644 index 0000000..b8e4b81 --- /dev/null +++ b/solutions/day-7/level2.js @@ -0,0 +1,49 @@ +// 1.question +function solveLinEquation(a, b, c) { + return -a / b; +} +// 2.question +// function solveQuadratic(a,b,c) { +// return Math.sqrt(-b + 4 * a * c) / 2*a; +// } +// // console.log(solveQuadratic()) // {0} +// console.log(solveQuadratic(1, 4, 4)) // {-2} +// console.log(solveQuadratic(1, -1, -2)) // {2, -1} +// console.log(solveQuadratic(1, 7, 12)) // {-3, -4} +// console.log(solveQuadratic(1, 0, -4)) //{2, -2} +// console.log(solveQuadratic(1, -1, 0)) //{1, 0} +// 3.question +function printArray(arr) { + for (let i = 0; i < arr.length; i++){ + console.log(arr[i]); + } +} +printArray([1, 2, 3, 4, 5]); +// 4.question +function showDateTime() { + let now = new Date(); + let day = now.getDate(), + mon = now.getMonth(), + year = now.getFullYear(), + hrs = now.getHours(), + min = now.getMinutes(); + console.log(`${day}/${mon}/${year} ${hrs}:${min}`); +} +// 5.question +function swap(a, b) { + let t; + t = a; + a = b; + b = t; + console.log(a,b); +} +swap(1, 2) +// 6.question +function reverseArray(arr) { + let rev = []; + for (let i = arr.length; i >= 0; i--){ + rev.push(arr[i]); + } + return rev; +} +// 7.question diff --git a/solutions/day-7/level3.js b/solutions/day-7/level3.js new file mode 100644 index 0000000..e69de29 diff --git a/solutions/day-7/tempCodeRunnerFile.js b/solutions/day-7/tempCodeRunnerFile.js new file mode 100644 index 0000000..cc6c50f --- /dev/null +++ b/solutions/day-7/tempCodeRunnerFile.js @@ -0,0 +1 @@ +solveQuadratic \ No newline at end of file