Skip to content

Instantly share code, notes, and snippets.

View periakteon's full-sized avatar

Masum Gökyüz periakteon

View GitHub Profile
@periakteon
periakteon / conditional-operator-ex.js
Created March 22, 2023 14:23
FreeCodeCamp: Use the Conditional (Ternary) Operator (Ex)
function findGreater(a, b) {
// koşul, yani "a>b" true olduğunda "a is greater" döner,
// kalan tüm durumlarda (else), "b is greater or equal" döner.
return a > b ? "a is greater" : "b is greater or equal";
}
/*
The syntax is --> " a ? b : c "
@periakteon
periakteon / ternary-if-else-ex.js
Created March 22, 2023 14:19
FreeCodeCamp: Use the Conditional (Ternary) Operator (if-else)
function findGreater(a, b) {
if(a > b) {
return "a is greater";
}
else {
return "b is greater or equal";
}
}
@periakteon
periakteon / parseInt-radix-solution.js
Created March 22, 2023 14:09
FreeCodeCamp: Use the parseInt Function with a Radix (Solution)
function convertToInteger(str) {
return parseInt(str, 2);
}
console.log(convertToInteger("10011"));
// 19
console.log(convertToInteger("111001"));
// 57
@periakteon
periakteon / parseInt-radix-challenge.js
Created March 22, 2023 14:07
FreeCodeCamp: Use the parseInt Function with a Radix (Challenge)
function convertToInteger(str) {
}
convertToInteger("10011");
@periakteon
periakteon / parseInt-radix-ex.js
Created March 22, 2023 13:57
FreeCodeCamp: Use the parseInt Function with a Radix (Ex)
const a = parseInt("11", 2);
console.log(a);
// 3
@periakteon
periakteon / parseInt-radix-form.js
Created March 22, 2023 13:54
FreeCodeCamp: Use the parseInt Function with a Radix
// iki parametre alır: (i) string, (ii) radix (taban)
parseInt(string, radix);
@periakteon
periakteon / parseInt-solution.js
Created March 22, 2023 13:13
FreeCodeCamp: Use the parseInt Function (Solution)
function convertToInteger(str) {
const parsedStr = parseInt(str);
return parsedStr;
}
console.log(convertToInteger("56"));
// 56
/*
@periakteon
periakteon / parseInt-challenge.js
Created March 22, 2023 13:08
FreeCodeCamp: Use the parseInt Function (Challenge)
function convertToInteger(str) {
}
convertToInteger("56");
@periakteon
periakteon / parseInt-ex.js
Created March 22, 2023 13:07
FreeCodeCamp: Use the parseInt Function (Ex)
const a = parseInt("007");
// a = 7
@periakteon
periakteon / random-whole-numbers-within-a-range-solution.js
Created March 22, 2023 13:04
FreeCodeCamp: Generate Random Whole Numbers within a Range (Solution)
function randomRange(myMin, myMax) {
return Math.floor(Math.random() * (myMax - myMin + 1) + myMin);
}
console.log(randomRange(5, 10));
// 9
console.log(randomRange(5, 10));
// 10