freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../es6/declare-a-read-only-variabl...

1.4 KiB

id title challengeType videoUrl localeTitle
587d7b87367417b2b2512b41 Declare a Read-Only Variable with the const Keyword 1

Description

undefined

Instructions

undefined

Tests

tests:
  - text: ''
    testString: 'getUserInput => assert(!getUserInput("index").match(/var/g),"<code>var</code> does not exist in your code.");'
  - text: ''
    testString: 'getUserInput => assert(getUserInput("index").match(/(const SENTENCE)/g), "<code>SENTENCE</code> should be a constant variable declared with <code>const</code>.");'
  - text: ''
    testString: 'getUserInput => assert(getUserInput("index").match(/(let i)/g), "<code>i</code> should be declared with <code>let</code>.");'
  - text: ''
    testString: 'getUserInput => assert(getUserInput("index").match(/console\.log\(\s*SENTENCE\s*\)\s*;?/g), "<code>console.log</code> should be adjusted to print the variable <code>SENTENCE</code>.");'

Challenge Seed

function printManyTimes(str) {
  "use strict";

  // change code below this line

  var sentence = str + " is cool!";
  for(var i = 0; i < str.length; i+=2) {
    console.log(sentence);
  }

  // change code above this line

}
printManyTimes("freeCodeCamp");

Solution

// solution required