Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
node_modules/
src/solutions.js
package-lock.json
testfile.js

34 changes: 34 additions & 0 deletions dist/testfile.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use strict";

// function iteration(n){
// const emptyArray =[];
// for( var i = 1; i <=n; i++ ){
// // console.log(i);
// emptyArray.push(i)
// }
// console.log(emptyArray);
// }
// iteration(20);
var jim = {
name: "Jim",
age: 60
};
var dilys = {
name: "Dilys",
age: 50
};
var marjorie = {
name: "Marjorie",
age: 65
};

var getAges = function getAges(people) {
// your code here
if (people.age > 65) {
return true;
}

return false;
};

console.log(getAges(jim));
36 changes: 31 additions & 5 deletions src/arrays.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,87 @@
const getNthElement = (index, array) => {
// your code here
return array[index];
};

const arrayToCSVString = array => {
// your code here
return array.join(",")

};

const csvStringToArray = string => {
// your code here
return string.split(",");

};

const addToArray = (element, array) => {
// your code here
array.push(element);
};

const addToArray2 = (element, array) => {
// your code here
const newArray = array.push(element)
console.log(newArray);
};

const removeNthElement = (index, array) => {
// your code here
return array.splice(index, 1);
};

const numbersToStrings = numbers => {
// your code here

return numbers.toString().split(',')
};

const uppercaseWordsInArray = strings => {
// your code here
return strings.map(name => name.toUpperCase());
};

const reverseWordsInArray = strings => {
// your code here
return strings.map(item => item.split('').reverse().join(''));


};

const onlyEven = numbers => {
// your code here
return numbers.filter(item => item % 2 === 0);
};

const removeNthElement2 = (index, array) => {
// your code here
};
// your code here



};
const elementsStartingWithAVowel = strings => {
// your code here
const vowels = ['a','e','i','o','u'];
return vowels.map(function(vowel) {
return strings.find(function(string) {
return string.toLowerCase().charAt(0) === vowel;
});
});
};

const removeSpaces = string => {
// your code here
return string.replace(/\s+/g, '')
};

const sumNumbers = numbers => {
// your code here
// your code here
return numbers.reduce((acc, curr) => acc + curr);
};

const sortByLastLetter = strings => {
// your code here

return strings.sort((a, b) => a.charCodeAt(a.length - 1) - b.charCodeAt(b.length - 1));
};

module.exports = {
Expand Down
52 changes: 48 additions & 4 deletions src/booleans.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,100 @@
/* eslint-disable func-names */
const negate = a => {
// your code here
return !a;
};

const both = (a, b) => {
// your code here
return a && b;
};

const either = (a, b) => {
// your code here
return a || b;
};

const none = (a, b) => {
// your code here
return !a && !b;
};

const one = (a, b) => {
// your code here
if (a || b || a) {
return true;
}
return false;
};

const truthiness = a => {
// your code here
// your code her
if (a) {
return true;
}
return false;
};

const isEqual = (a, b) => {
// your code here
return a === b;
};

const isGreaterThan = (a, b) => {
// your code here
return a > b;
};

const isLessThanOrEqualTo = (a, b) => {
// your code here
return a <= b;
};

const isOdd = a => {
// your code here
if (a % 2 !== 0) {
return true;
}
return false;
};

const isEven = a => {
// your code here
if (a % 2 == 0) {
return true;
// eslint-disable-next-line no-else-return
} else {
return false;
}
};

const isSquare = a => {
// your code here
return Math.sqrt(a) === Math.round(Math.sqrt(a));
};

const startsWith = (char, string) => {
const startsWith = (string, char) => {
// your code here
if (string.startsWith(char)) {
return true;
}
return false;
};

const containsVowels = string => {
// your code here
const containsVowels = function(string) {
const vowels = ['a','e','i','o','u'];
// var stringLowercase = string.toLowerCase()
for(i = 0; i < vowels.length; i++){
if (vowels.includes(string.toLowerCase()[i])){
return true;
}
}
return false;
};

const isLowerCase = string => {
// your code here
return string == string.toLowerCase() && string != string.toUpperCase();
};

module.exports = {
Expand All @@ -75,3 +114,8 @@ module.exports = {
containsVowels,
isLowerCase
};

// program to count the number of vowels in a string

// defining vowels

143 changes: 143 additions & 0 deletions src/dist/booleans.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
"use strict";

/* eslint-disable func-names */
var negate = function negate(a) {
// your code here
return !a;
};

var both = function both(a, b) {
// your code here
return a && b;
};

var either = function either(a, b) {
// your code here
return a || b;
};

var none = function none(a, b) {
// your code here
return !a && !b;
};

var one = function one(a, b) {
// your code here
if (a || b || a) {
return true;
}

return false;
};

var truthiness = function truthiness(a) {
// your code her
if (a) {
return true;
}

return false;
};

var isEqual = function isEqual(a, b) {
// your code here
return a === b;
};

var isGreaterThan = function isGreaterThan(a, b) {
// your code here
return a > b;
};

var isLessThanOrEqualTo = function isLessThanOrEqualTo(a, b) {
// your code here
return a <= b;
};

var isOdd = function isOdd(a) {
// your code here
if (a % 2 !== 0) {
return true;
}

return false;
};

var isEven = function isEven(a) {
// your code here
if (a % 2 == 0) {
return true; // eslint-disable-next-line no-else-return
} else {
return false;
}
};

var isSquare = function isSquare(a) {
// your code here
return Math.sqrt(a) === Math.round(Math.sqrt(a));
};

var startsWith = function startsWith(string, _char) {
// your code here
if (string.startsWith(_char)) {
return true;
}

return false;
};

var containsVowels = function containsVowels(string) {
var vowels = ["a", "e", "i", "o", "u"]; // convert vowels to same casing

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;

try {
for (var _iterator = string.toLowerCase()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var letterInString = _step.value;

if (vowels.includes(letterInString)) {
return true;
}

return false;
} // your code here

} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
};

var isLowerCase = function isLowerCase(string) {// your code here
};

module.exports = {
negate: negate,
both: both,
either: either,
none: none,
one: one,
truthiness: truthiness,
isEqual: isEqual,
isGreaterThan: isGreaterThan,
isLessThanOrEqualTo: isLessThanOrEqualTo,
isOdd: isOdd,
isEven: isEven,
isSquare: isSquare,
startsWith: startsWith,
containsVowels: containsVowels,
isLowerCase: isLowerCase
}; // program to count the number of vowels in a string
// defining vowels
Loading