Created
November 24, 2021 17:29
-
-
Save vladislavaSim/67b80c0056f003b5f4cd6151a3744842 to your computer and use it in GitHub Desktop.
homework
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 str = 'I learn JavaScript!'; | |
console.log(str.length); | |
console.log(str.substr(2, 5)); | |
console.log(str.substring(2, 7)); | |
console.log(str.slice(2, 7)); | |
console.log(str.indexOf('learn')); | |
const string = 'Чтобы избавиться от лишнего веса, нужно всего лишь не жрать'; | |
let n = 50; | |
let result; | |
if(string.length > n) { | |
result = string.slice(0, n) + '...' | |
} else { | |
result = string | |
} | |
console.log(result); | |
let strJs = 'js'; | |
console.log(strJs.toUpperCase()); | |
console.log(strJs.toLowerCase()); | |
let randNum = Math.floor(Math.random() * (100 - 1 + 1)) + 1; | |
console.log(randNum); | |
let randNumsArray = []; | |
for(let i = 0; i < 10; i++) { | |
let randNum = Math.floor(Math.random() * (100 - 1 + 1)) + 1; | |
randNumsArray.push(randNum) | |
} | |
console.log(randNumsArray); | |
let string2 = 'aaa bbb ccc'; | |
console.log(string2.substr(4, 3)); | |
console.log(string2.substring(4, 7)); | |
console.log(string2.slice(4, 7)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment