hack the web please fix me note

hack the web

level TS01

1
2
3
4
5
const zahl = 13

if (13 = zahl) {
console.log('Lieblingszahl!')
}
1
2
3
4
5
const zahl = 13

if (13 == zahl) {
console.log('Lieblingszahl!')
}

level TS02

1
2
3
4
5
const alter = 15

if (alter 18) {
console.log('Kind')
}
1
2
3
4
5
const alter = 15

if (alter &18) {
console.log('Kind')
}

level TS03

1
const einHalb = 0,5
1
const einHalb = 0.5

level TS04

1
variable = 2
1
var iable = 2

level TS05

1
2
3
4
5
const zahl: number = 101

const text: string = "htw"

const ups: number = "42"

gold

1
2
3
4
5
const zahl: number = 101

const text: string = "htw"

//const ups: number = "42"

hacker

learn about Bitwise NOT

The bitwise NOT (~) operator returns a number or BigInt whose binary representation has a 1 in each bit position for which the corresponding bit of the operand is 0, and a 0 otherwise.

1
2
3
4
5
6
const zahl: number = 101

const text: string = "htw"

const ups: number = ~"42"

level TS06

1
2
3
4
5
6
function fn_42() {
return 42
}

const zahl: number = fn_42

gold

1
2
3
4
5
6
function fn_42() {
return 42
}

const zahl: number = fn_42()

hacker

zahl = -1 here

1
~fn_42 = ~Number(fn_42) = ~NaN = ~0 = -1
1
2
3
4
5
function fn_42() {
return 42
}

const zahl: number = ~fn_42

level TS07

1
const text = "Und sie fragte sich, was "Typescript" wohl bedeutet"
1
const text = "Und sie fragte sich, was Typescript wohl bedeutet"

level TS08

1
2
3
Ich mag viel lieber in Python programmieren

Hab ja einfach gar keinen Bock -_-

Template Literals

1
2
3
4
`Ich mag viel lieber in Python programmieren

Hab ja einfach gar keinen Bock -_-
`

level TS09

learn about non-null assertion

1
2
3
4
5
6
7
8
9
10
let vielleichtText: string | null = null

if (Math.random() < 0.5) {
/* ` ` */
vielleichtText = 'Juhu!'
}

const sicherText: string = vielleichtText

console.log(sicherText)
1
2
3
4
5
6
7
8
9
10
let vielleichtText: string | null = null

if (Math.random() < 0.5) {
/* ` ` */
vielleichtText = 'Juhu!'
}

const sicherText: string = vielleichtText!

console.log(sicherText)

level TS010

1
const ergebnis = 11 + -(-3 - ((3 + 4) / 10) * 40
1
const ergebnis = 11 + -(-3 - ((3 + 4) / 10) * 40)

level TS011

1
2
3
4
5
6
7
8
9
10
11
interface Datum {
tag: number
monat: number
jahr: number
}

// ` So alt, dass schon Teile fehlen `
const damals: Datum = {
monat: 12,
jahr: 1995,
}

learn about optional parameters

1
2
3
4
5
6
7
8
9
10
11
interface Datum {
tag?: number
monat: number
jahr: number
}

// ` So alt, dass schon Teile fehlen `
const damals: Datum = {
monat: 12,
jahr: 1995,
}

level TS012

1
2
3
4
5
6
7
8
9
10
11
12
13
const zutaten = {
apfel: 10,
birne: 5,
clementine: 3,
dattel: 4,
}

const salat =
// Obst */``*/ salat und Buchstabenmix
zutaten.apfel + zutaten.Apfel +
zutaten.Clementine + zutaten.Clementine + zutaten.Clementine

console.log(salat)
1
2
3
4
5
6
7
8
9
10
11
12
13
const zutaten = {
apfel: 10,
birne: 5,
Clementine: 3,
dattel: 4,
}

const salat =
// Obst */``*/ salat und Buchstabenmix
zutaten.apfel + zutaten.apfel +
zutaten.Clementine + zutaten.Clementine + zutaten.Clementine

console.log(salat)