Skip to content

Instantly share code, notes, and snippets.

View jaamaalxyz's full-sized avatar
🎯
Focusing

Md. Jamal Uddin jaamaalxyz

🎯
Focusing
View GitHub Profile
@jaamaalxyz
jaamaalxyz / fibonacciSeries.py
Created January 29, 2018 07:18
fibonacciSeries created by JamalUddin - https://repl.it/@JamalUddin/fibonacciSeries
# Fibonacci series using mem cache for effiecient solution
# Author: Jamal Uddin
# Date: 29.01.2018
def fib(n, _cache={}):
if n in _cache:
return _cache[n]
elif n > 1:
return _cache.setdefault(n, fib(n - 1) + fib(n - 2))
return n
// Price for groceries
var potatoPrice = 20;
var tomatoPrice = 30;
var fishPrice = 160;
// Price for groceries
var potatoPrice = 20;
var tomatoPrice = 30;
var fishPrice = 160;
// Output
console.log(potatoPrice); // Output should be: 20
console.log(tomatoPrice); // Output should be: 30
console.log(fishPrice); // Output should be: 160
// Previuos groceries prices
var potatoPrice = 20;
var tomatoPrice = 30;
var fishPrice = 160;
console.log(potatoPrice); //should be present: 20
// If we want to change potato price
potatoPrice = 25;
console.log(potatoPrice); //should be present: 25
let mango; // Declaration or Initialization
mango = "We are mango people"; // String type data asisgned in mango variable
// Or you can declare or initialize and assign value all in onec.
let myNumber = 32;
let myString = 'Hello, World!';
let myBoolean = true;
// If you want to see the output
console.log(mango); // We are mango people
// const type variable declaration
const PI = 3.14; // Global value of pi
const TAX_RATE = 8.5; // maybe your tax rate 8.5%
const INTEREST_RATE = 12; // Bank interest rate is 12%
// output
console.log(PI); // 3.14
console.log(TAX_RATE); // 8.5
console.log(INTEREST_RATE); // 12
// Global scope
var num = 5;
function globalVar() {
console.log(num); // num = 5
num = 8;
console.log(num); // num = 8
}
console.log(num); // num = 5
let id = function() {
const num = 10;
console.log(num); // output: 10
};
console.log(id()); // 10
console.log(num); // ReferenceError: num is not defined
var singleQuotes = 'This is a string in single quotes.';
var doubleQuotes = "This is a string in double quotes.";
let txtOne = "I'm from Dhaka, Bangladesh"; // I'm from Dhaka, Bangladesh
let txtTwo = 'I'm a programmer'; // SyntaxError: Unexpected identifier
// If you want to pass this Error let's do this way
let txtTwo = 'I\'m a programmer';
console.log(txtTwo); // I'm a programmer
var num1 = 30;
var num2 = 5 / 0; // will return Infinity
var num3 = -5 / 0; // will return -Infinity
let x = 20 / "Shark"; // Will return NaN
const PI = 3.14;
console.log(num1); // Output: 30
console.log(num2); // Output: Infinity
console.log(num3); // Output: -Infinity
console.log(x); // Output: NaN