renamed
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const secretMes1 = "How's%20it%20going%3F";
|
||||
const secretMes2 = "How's it going?";
|
||||
const decodedComp = decodeURIComponent(secretMes1);
|
||||
console.log(decodedComp);
|
||||
const encodedComp = encodeURIComponent(secretMes2);
|
||||
console.log(encodedComp);
|
||||
const uri = "http://www.basescripts.com?=Hello World";
|
||||
const encoded = encodeURI(uri);
|
||||
console.log(encoded);
|
||||
|
||||
How's it going?
|
||||
How's%20it%20going%3F
|
||||
http://www.basescripts.com?=Hello%20World
|
||||
@@ -0,0 +1,6 @@
|
||||
const arr = ["Laurence", "Mike", "Larry", "Kim", "Joanne", "Laurence", "Mike", "Laurence", "Mike", "Laurence", "Mike"];
|
||||
const arr2 = arr.filter ( (value, index, array) => {
|
||||
console.log(value,index,array.indexOf(value));
|
||||
return array.indexOf(value) === index
|
||||
});
|
||||
console.log(arr2);
|
||||
@@ -0,0 +1,8 @@
|
||||
const myArr = [1,4,5,6];
|
||||
const myArr1 = myArr.map(function(ele){
|
||||
return ele * 2;
|
||||
});
|
||||
console.log(myArr1);
|
||||
|
||||
const myArr2 = myArr.map((ele)=> ele*2);
|
||||
console.log(myArr2);
|
||||
@@ -0,0 +1,12 @@
|
||||
const val = "thIs will be capiTalized for each word";
|
||||
function wordsCaps(str) {
|
||||
str = str.toLowerCase();
|
||||
const tempArr = [];
|
||||
let words = str.split(" ");
|
||||
words.forEach(word => {
|
||||
let temp = word.slice(0, 1).toUpperCase() + word.slice(1);
|
||||
tempArr.push(temp);
|
||||
});
|
||||
return tempArr.join(" ");
|
||||
}
|
||||
console.log(wordsCaps(val));
|
||||
@@ -0,0 +1,8 @@
|
||||
let val = "I love JavaScript";
|
||||
val = val.toLowerCase();
|
||||
let vowels = ["a","e","i","o","u"];
|
||||
vowels.forEach((letter,index) =>{
|
||||
console.log(letter);
|
||||
val = val.replaceAll(letter,index)
|
||||
})
|
||||
console.log(val);
|
||||
@@ -0,0 +1,13 @@
|
||||
console.log(Math.ceil(5.7));
|
||||
console.log(Math.floor(5.7));
|
||||
console.log(Math.round(5.7));
|
||||
console.log(Math.random());
|
||||
console.log(Math.floor(Math.random()*11)); // 0-10
|
||||
console.log(Math.floor(Math.random()*10)+1); // 1-10;
|
||||
console.log(Math.floor(Math.random()*100)+1); // 1-100;
|
||||
function ranNum(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
for (let x = 0; x < 100; x++) {
|
||||
console.log(ranNum(1, 100));
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
let future = new Date(2025, 5, 15);
|
||||
console.log(future);
|
||||
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
||||
let day = future.getDate();
|
||||
let month = future.getMonth();
|
||||
let year = future.getFullYear();
|
||||
let myDate = `${months[month-1]} ${day} ${year}`;
|
||||
console.log(myDate);
|
||||
@@ -0,0 +1,16 @@
|
||||
let str = "JavaScript";
|
||||
|
||||
function scramble(val) {
|
||||
let max = val.length;
|
||||
let temp = "";
|
||||
for(let i=0;i<max;i++){
|
||||
console.log(val.length);
|
||||
let index = Math.floor(Math.random() * val.length);
|
||||
temp += val[index];
|
||||
console.log(temp);
|
||||
val = val.substr(0, index) + val.substr(index + 1);
|
||||
console.log(val);
|
||||
}
|
||||
return temp
|
||||
}
|
||||
console.log(scramble(str));
|
||||
@@ -0,0 +1,27 @@
|
||||
const endDate = "Sept 1 2022";
|
||||
|
||||
function countdown() {
|
||||
const total = Date.parse(endDate) - new Date();
|
||||
const days = Math.floor(total / (1000 * 60 * 60 * 24));
|
||||
const hrs = Math.floor((total / (1000 * 60 * 60)) % 24);
|
||||
const mins = Math.floor((total / 1000 / 60) % 60);
|
||||
const secs = Math.floor((total / 1000) % 60);
|
||||
return {
|
||||
days,
|
||||
hrs,
|
||||
mins,
|
||||
secs
|
||||
};
|
||||
}
|
||||
|
||||
function update() {
|
||||
const temp = countdown();
|
||||
let output = "";
|
||||
for (const property in temp) {
|
||||
output += (`${property}: ${temp[property]} `);
|
||||
}
|
||||
console.log(output);
|
||||
setTimeout(update, 1000);
|
||||
}
|
||||
|
||||
update();
|
||||
Reference in New Issue
Block a user