This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Capitalize Letters | |
const word = "i love you"; | |
const firstL = function (word) { | |
const w = word | |
.toLowerCase() | |
.split(" ") | |
.map((word) => { | |
// return word.slice(0,1).toUpperCase()+word.slice(1) | |
return word[0].toUpperCase() + word.substr(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For example: 5! = 1 * 2 * 3 * 4 * 5 = 120 | |
function factorialize(num) { | |
let numFac=[] ; | |
for(let i=1;i<=num;i++){ | |
if(numFac.indexOf(num[i])==-1){ | |
numFac.push(i); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Return the length of the longest word in the provided sentence. | |
function findLongestWordLength(str) { | |
const strSplit = str.split(" ").map((val, i, arr) => { | |
return val.split("").length; | |
}); | |
const strL = Math.max(...strSplit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr = [ | |
[-1, 1, -7, -8], | |
[-10, -8, -5, -2], | |
[0, 9, 7, -1], | |
[4, 4, -2, 1], | |
]; | |
function diagonalDifference(arr) { | |
// Extraction of the primary diagonal | |
let left = arr | |
.map((e, i) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Integer Reversal | |
const number=123456; | |
const rev = function (num) { | |
const numRev = number | |
.toString() | |
.split("") | |
.reverse() | |
.join(""); | |
return parseInt(numRev); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays. | |
function largestOfFour(arr) { | |
subArr=[]; | |
arr.map((val)=>{ | |
return subArr.push(Math.max(...val)) | |
}) | |
return subArr; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [7, 69, 2, 221, 8974]; | |
function miniMaxSum(arr) { | |
let result=[] | |
arr = arr.sort((a, b) => { | |
return a - b; | |
}); | |
result.push(arr.slice(0,4).reduce((acc,e)=>acc+e)) | |
result.push(arr.reverse().slice(0,4).reduce((acc,e)=>acc+e)) | |
console.log(...result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr = [3, 2, 1, 3]; | |
function countDuplicate(arr) { | |
let number = 0; | |
arr.find((item, index) => { | |
if (arr.indexOf(item) !== index) { | |
number=item // find the duplicate (return 3) | |
} | |
}); | |
// you can use just the function below if you know the exact value for the duplicate | |
function getOccurrence(array, value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function kangaroo(x1, v1, x2, v2) { | |
if (x1 > x2) { | |
if (v1 >= v2) return "NO"; | |
} | |
if (x2 > x1) { | |
if (v2 >= v1) return "NO"; | |
} | |
let jump = (x2 - x1) / (v2 - v1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First time: | |
git config --global user.name "Stefana" -it is important to use the same username as on github | |
git config --global user.email "stefana@...." | |
Every time: | |
git init -Create a new local repository | |
git add -A , Add one or more files to staging | |
git commit -m, -first compit | |
git status -List the files you've changed and those you still need to add or commit | |
git remote add origin <server(link from your repo)> |
OlderNewer