This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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> |
NewerOlder