×
          
              
          
      
      Clear all filters including search bar
          
        Valeri Tandilashvili's JavaScript Notes
      
    myName will be concatenated with the stringlet myName = 'Valeri';
console.log('My name is ' + myName + '.');The result will be:My name is Valeri.5+5; // 10
Multiplication of two integers5*5; // 25
If we add a number to a string, the number will be converted into a string and the result will be a concatenation of the two strings5+'12'; // 512
String multiplied by an integer5*'5'; // 25
Multiplication of a string (but not numeric string) and a number5*'t'; // NaN
The first operation of the expression is addition and then concatenation5+5+'2'; // 102function mapString(string) {
  let map = {};
  for (let i = 0; i < string.length; i++) {
    let letter = string[i];
    if (map[letter]) {
      map[letter].push(i);
    } else {
      map[letter] = [i];
    }
  }
  return map;
}
console.log(mapString('blblllaaha'))for (let i = 0; i < 2; i++) {
   console.log(i)
}1. false: the boolean value false
2. 0: the number zero
3. '': the empty string, a string with no characters
4. NaN : stands for "Not a Number", usually caused by math errors
5. undefined: a variable's value before it is assigned a value
6. null: a blank value that can be assigned to a variablefunction calculateSum(numberArray) {
    let sum = 0;
    for (let num of numberArray) {
        sum += num;
    }
    return sum;
}function lessThanFive(numbers) {
  for (let number of numbers) {
    if (number > 4) {
      return false;
    }
  }
  return true;
}
function invert(x) {
  if (x === 0) {
     return 'input was zero';
  } else {
    return 1 / x;
  }
}
The function will still work using an if statement instead of an if...else statementfunction invert(x) {
  if (x === 0) {
     return 'input was zero';
  }
  return 1 / x;
}.slide document.querySelector('.slide').remove()
Removes all the elements with the specified classdocument.querySelectorAll('.slide').remove()async function start() {
  try {
    fetch("https://dog.ceo/api/breeds/list/all").then(function(response) {
      return response.json()
    }).then(function(data) {
      createBreedList(data.message)
    })
  } catch (e) {
    console.log("There was a problem fetching the breed list.")
  }
}
Fetch with async & await keywordsasync function start() {
  try {
    const response = await fetch("https://dog.ceo/api/breeds/list/all")
    const data = await response.json()
    createBreedList(data.message)
  } catch (e) {
    console.log("There was a problem fetching the breed list.")
  }
}