Skip to content

Instantly share code, notes, and snippets.

View Octagon-simon's full-sized avatar
Turning red flags into red tests that pass.

Simon Ugorji (Octagon) Octagon-simon

Turning red flags into red tests that pass.
View GitHub Profile
function calcDate(date1, date2){
/*
* calcDate() : Calculates the difference between two dates
* @date1 : "First Date in the format MM-DD-YYYY"
* @date2 : "Second Date in the format MM-DD-YYYY"
* return : Array
*/
//new date instance
const dt_date1 = new Date(date1);
function calcDate(date1, date2){
/*
* calcDate() : Calculates the difference between two dates
* @date1 : "First Date in the format MM-DD-YYYY"
* @date2 : "Second Date in the format MM-DD-YYYY"
* return : Array
*/
//new date instance
const dt_date1 = new Date(date1);
const dt_date2 = new Date(date2);
//Call the function
calcDate("11-19-2021", "12-12-2026");
(condition_to_check) ? (action_to_execute_if_condition_is_true) : (action_to_execute_if_condition_is_false)
var x = 20;
( x == 20 ) ? (console.log("x is 20")) : (console.log("x is not 20"))
var x = 20;
( x == 0 ) ? (console.log("x is 0")) :
( x == 10 ) ? (console.log("x is 10")) :
( x == 20 ) ? (console.log("x is 20")) :
(console.log("x is unknown"));
var x = 20;
if( x == 0 ) {
(console.log("x is 0"));
}else if( x == 10 ) {
(console.log("x is 10"));
}else if( x == 20 ) {
(console.log("x is 20"));
}else {
(console.log("x is unknown"))
}
var x = 0; var y = 0; var z = 0;
(!x && !y && !z) ? (
console.log('reassigning the variables'),
x = 10,
y = 10,
z = 10,
console.log("x is now "+x),
console.log("y is now "+y),
console.log("z is now "+z),
console.log('variables have been reassigned')
$a = null; $b = null; $c = null;
(!$a && !$b && !$c) ?
(
($a = 1).
($b = 2).
($c = 3).
(print("A, B, C = ".$a.' '.$b.' '.$c))
)
: (print("A, B AND C are not empty!"));
$f = 0;
($f == 0) ?
echo("f is 0")
: echo("f is not 0")