This file contains 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
// String to number | |
const str = '123'; | |
const num1 = parseInt(str); | |
const num2 = Number(str); | |
// Number to string | |
const n = 123; | |
const s = n.toString(); |
This file contains 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
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]; |
This file contains 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
let a = [9, 2, 3]; | |
a.length | |
// a.push() | |
// a.pop() | |
// a.unshift() | |
// a.splice() | |
// a.slice() | |
// a.reverse() | |
// a.join() |
This file contains 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
'hello world' | |
"hello world" | |
123 | |
1.23 | |
-123 | |
false | |
true |
This file contains 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
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); |
This file contains 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
# 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 |
NewerOlder