Skip to content

Commit 36aacf5

Browse files
committed
#4 - JavaScript
1 parent 821aef5 commit 36aacf5

File tree

1 file changed

+63
-8
lines changed
  • Roadmap/04 - CADENAS DE CARACTERES/typescript

1 file changed

+63
-8
lines changed

Roadmap/04 - CADENAS DE CARACTERES/typescript/RicJDev.ts

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,78 @@
11
//EJERCICIO
22
//Acceso a caracteres específicos
3-
//Subcadenas
3+
const myAlphabet: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
4+
5+
console.log(myAlphabet[17] + myAlphabet[8] + myAlphabet[2])
6+
7+
const nameChart1: string = myAlphabet.charAt(17)
8+
const nameChart2: string = myAlphabet.charAt(8)
9+
const nameChart3: string = myAlphabet.charAt(2)
10+
11+
console.log(nameChart1, nameChart2, nameChart3)
12+
13+
const rPosition: number = myAlphabet.indexOf('R')
14+
15+
console.log(`La letra R es la número ${rPosition + 1} de nuestro alfabeto`)
16+
417
//Longitud
5-
//Concatenación
6-
let myString1: string = 'Hola, '
7-
let myString2: string = 'TypeScript'
18+
const phrase: string = 'Me encantan las papas fritas'
19+
20+
console.log(`\"${phrase}\" tiene ${phrase.length} caracteres`)
21+
22+
//Subcadenas
23+
const phraseSlice: string = phrase.slice(16)
24+
25+
console.log(phraseSlice)
26+
27+
const heroes: string = 'Batman le gana a Superman'
28+
const Batman: string = heroes.substring(0, 6)
29+
const Superman: string = heroes.substring(17)
30+
31+
console.log(Batman)
32+
console.log(Superman)
833

9-
let message: string = myString1.concat(myString2)
34+
//Concatenación
35+
let action: string = ' está peleando con '
1036

11-
console.log(message)
37+
console.log(Batman.concat(action, Superman))
38+
console.log(Batman + action + Superman)
1239

1340
//Repetición
41+
let ric: string = 'Ric '
42+
43+
console.log(ric.repeat(3))
44+
1445
//Recorrido
46+
for (let i = 0; i < myAlphabet.length; i++) {
47+
console.log(myAlphabet[i])
48+
}
49+
1550
//Conversión a mayúsculas y minúsculas
51+
const fruits: string[] = ['fresa', 'PARCHITA', 'LiMÓn', 'Mango']
52+
53+
fruits.forEach((fruit) => {
54+
console.log(fruit.toUpperCase())
55+
})
56+
57+
fruits.forEach((fruit) => {
58+
console.log(fruit.toLowerCase())
59+
})
60+
1661
//Reemplazo
62+
let musicPlayer = 'Music Player current song: The Pretender - Foo Fighters'
63+
64+
console.log(musicPlayer)
65+
console.log(musicPlayer.replace('The Pretender - Foo Fighters', 'Monster - Skillet'))
66+
1767
//División
68+
1869
//Unión
70+
1971
//Interpolación
72+
console.log(`\n\"TypeScript es JavaScript premium\" \n\n\t\t\t${ric.toUpperCase()}`)
73+
2074
//Verificación
75+
2176
//Otros
2277

2378
//EXTRA
@@ -63,5 +118,5 @@ function analyzeTheseWords(word1: string, word2: string) {
63118
isogram(word2)
64119
}
65120

66-
analyzeTheseWords('Roma', 'Amor')
67-
analyzeTheseWords('Radar', 'Paloma')
121+
// analyzeTheseWords('Roma', 'Amor')
122+
// analyzeTheseWords('Radar', 'Paloma')

0 commit comments

Comments
 (0)