Skip to content

Instantly share code, notes, and snippets.

@vladislavaSim
Created November 24, 2021 17:29
Show Gist options
  • Save vladislavaSim/67b80c0056f003b5f4cd6151a3744842 to your computer and use it in GitHub Desktop.
Save vladislavaSim/67b80c0056f003b5f4cd6151a3744842 to your computer and use it in GitHub Desktop.
homework
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