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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device --> | |
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png"> | |
<link rel="stylesheet" href="style.css"> | |
<title>Frontend Mentor | Intro component with sign up form</title> |
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
// METHOD 1 (IN-BUILT FUNCTION) | |
function convertBaseToBinary(bin) { | |
return parseInt(bin, 2).toString(10); // Convert arguments from one radix/base to radix in toString()/ | |
} | |
// USING FOR LOOP & parseInt FUNCTION | |
function bin2dec(bin) { | |
var decimal = 0; | |
for (var index = bin.length - 1; index >= 0; index--) { |
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
fn main() { | |
let answer = square(10); | |
println!("The answer is {}", answer); | |
} | |
fn square(num: i32) -> i32 { | |
num * num | |
} | |
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
// Learning ternary operators | |
// Traditional way | |
let message; | |
if (login == 'Employee') { | |
message = 'Hello'; | |
} else if (login == 'Director') { | |
message = 'Greetings'; | |
} else if (login == '') { |
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
// writing if statements as swich statements | |
//This IF/ELSE statement | |
if(x === 'value1'){ | |
... | |
} else if (x = 'value2'){ | |
... | |
} else{ | |
... |
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
fn main() { | |
let age = 18; | |
if x < 18 { | |
println!('you are too young'); | |
} else if x == 18 { | |
println!('you are just the right age'); | |
} else { | |
println!(' wow, you are old, enjoy !!! '); | |
} | |
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
// This is just snippets showing how signature functions works | |
// Generate private key and public key | |
generate_keys(){ | |
return (priv_key, pub_key); | |
} | |
// sign a message using you private key( still kept secret) | |
sign(message, priv_key){ | |
return signature; // a signature is returned |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
<title>Order | Bethany's Pie Shop</title> | |
<link rel="stylesheet" href="site.css" type="text/css" /> | |
<style> | |
@media only screen and (min-width: 768px) { |
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
//Normal function | |
function sum(num1, num2){ | |
return num1 + num2; | |
} | |
let output =sum(10, 4); | |
console.log(output) | |
//Arrow function | |
let sum = (num1, num2) => return num1 + num2; |
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 the first task, you have to create a simple function — chooseName() — that prints | |
a random name from the provided array (names) to the provided paragraph (para), and then run it once. */ | |
const names = ['Chris', 'Li Kang', 'Anne', 'Francesca', 'Mustafa', 'Tina', 'Bert', 'Jada'] | |
const para = document.createElement('p'); | |
function chooseName(){ | |
let eachName = names[Math.floor(Math.random() * names.length)]; | |
para.textContent = eachName; | |
} |
OlderNewer