Skip to content

Instantly share code, notes, and snippets.

@daf78
daf78 / __replit_main__
Created November 27, 2018 19:32
WryLimegreenSableantelope created by daf78 - https://repl.it/@daf78/WryLimegreenSableantelope
// < Hacking Task #warmUp >");
var battery = 100; //how much battery your laptop has left
var hackedTerminals = 0; //how many terminals you have hacked
var username = prompt('What is your username:', 'username here...');
var welcomeMessage =
'fSociety distro is booting... Please enter your username: ';
console.log(welcomeMessage + username);
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:31
JavaScript_exercices_Udemy created by daf78 - https://repl.it/@daf78/JavaScriptexercicesUdemy
/*
//Les variables
//commande prompt
var name = prompt("what is your name?");
alert(name);
//Strings
console.log('What a "String" is?');
console.log("What a \"String\" is?");
console.log("What a 'String' is?");
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:31
javascript_codecademy created by daf78 - https://repl.it/@daf78/javascriptcodecademy
/*
function Person(first,last,age) {
this.firstname = first;
this.lastname = last;
this.age = age;
var bankBalance = 7500;
var returnBalance = function() {
return bankBalance;
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:31
CoralProperConure created by daf78 - https://repl.it/@daf78/CoralProperConure
Empty file
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:30
dog years created by daf78 - https://repl.it/@daf78/dog-years
const myAge = 39; //my age in years
let earlyYears = 2;
earlyYears *= 10.5; //21
let laterYears = myAge - earlyYears; //18: subtracts the first two years from my age
laterYears *= 4; //72: calculate the nbr of dog years accounted for by my later years
let myAgeInDogYears = earlyYears + laterYears; // my age in dog years
const myName = 'David';
myName.toLowerCase(); //make all letters in my name lowercase
console.log(`My name is ${myName}. I am ${myAgeInDogYears} years old in dog years.`); //print out to the console my age in dog years
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:30
Calculate Sleep Debt created by daf78 - https://repl.it/@daf78/Calculate-Sleep-Debt
const getSleepHours = day => {
day = day.toLowerCase();
switch (day) {
case 'monday':
return 7;
break;
case 'tuesday':
return 6;
break;
case 'wednesday':
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:30
Whale Talk created by daf78 - https://repl.it/@daf78/Whale-Talk
const input = 'I am learning JavaScript!'.toLowerCase();
const vowels = ['a', 'e', 'i', 'o', 'u'];
let resultArray = [];
for (let i = 0; i < input.length; i++) {
for (let j = 0; j < vowels.length; j++) {
if (input[i] === vowels[j]) {
resultArray.push(input[i]);
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:29
Cards game: Find a Spade with while loops! created by daf78 - https://repl.it/@daf78/Cards-game-Find-a-Spade-with-while-loops
const cards = ['Diamond', 'Spade', 'Heart', 'Club'];
let currentCard = 'Heart';
while (currentCard !== 'Spade') {
console.log(currentCard);
let randomNumber = Math.floor(Math.random()*4);
currentCard = cards[randomNumber];
}
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:29
Password Validator created by daf78 - https://repl.it/@daf78/Password-Validator
// Verifies the password has a special character
function hasSpecialCharacter (input) {
const specialCharacters = ['!', '@', '#', '$', '%', '^', '&', '*'];
for (var i =0; i <input.length; i++) {
for (var j =0; j <specialCharacters.length; j++) {
if (input[i] === specialCharacters[j]) {
return true;
}
}
}
@daf78
daf78 / __replit_main__
Created November 27, 2018 19:29
Udacity_Quiz: 99 Bottles of Juice (4-2) created by daf78 - https://repl.it/@daf78/UdacityQuiz-99-Bottles-of-Juice-4-2
/*
* Programming Quiz: 99 Bottles of Juice (4-2)
*
* Use the following `while` loop to write out the song "99 bottles of juice".
* Log the your lyrics to the console.
*
* Note
* - Each line of the lyrics needs to be logged to the same line.
* - The pluralization of the word "bottle" changes from "2 bottles" to "1 bottle" to "0 bottles".
*/