Skip to content

Instantly share code, notes, and snippets.

// String to number
const str = '123';
const num1 = parseInt(str);
const num2 = Number(str);
// Number to string
const n = 123;
const s = n.toString();
let variable = 1;
const str = 'Coding bootcamp';
for (const letter of str) {
console.log(letter);
}
for (let i = 0; i < str.length; i++) {
const letter = str[i];
let a = [9, 2, 3];
a.length
// a.push()
// a.pop()
// a.unshift()
// a.splice()
// a.slice()
// a.reverse()
// a.join()
'hello world'
"hello world"
123
1.23
-123
false
true
const str = 'strings';
const num = 1.0;
const bool = false;
const arr = [1, 2, 3];
console.log(typeof str);
console.log(typeof num);
console.log(typeof bool);
console.log(typeof arr);
# Returns the nth iteration of the fibonacci sequence
# n: 0 1 2 3 4 5 6
# output: 1 1 2 3 5 8 13
def fibonacci(n):
# Base case
if n == 0 or n == 1:
return 1
# Recursive case