Skip to content

Variables; Data Types (number, string, boolean, undefined, null); prompt; comparison and logical operators; type conversion

Notifications You must be signed in to change notification settings

JavaScriptADI/assignment-2-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assignment 2

Work in src/ directory. Ignore other files, just use or create a new js file and solve the following questions in it. Sometimes it might be better to create additional files for different tasks. For example, if you are working on a task that requires a lot of code, you can create a separate file for that task. Variables; Data Types (number, string, boolean, undefined, null); prompt; comparison and logical operators; type conversion

  1. Declare a variable and assign a string as a value. Make sure the string is at least 6 characters long. Print the variable to the console.
  2. What is the difference between "5" and 5?
  3. Declare a variable and assign a number as a value. Make sure the number is greater than 9. Print the variable to the console.
  4. Declare a variable and assign a boolean as a value. Print the variable to the console.
  5. What operators give us a boolean result?
  6. Declare a variable with the value of "Hello". Covert the value to upper case and print the converted value to the console.
  7. Declare another variable with the value of "World". Convert the value to lower case and print the converted value to the console.
  8. Given code:
    let text = 'Hello';
    text.toUpperCase();
    console.log(text);
    What is the value of the variable text before and after the method is called?
  9. Given code:
    let text;
    console.log(text);
    What is the value of the variable text?
  10. Find an error in the following code:
    let text = 'Hello';
    console.log(text.toLowercase());
  11. Find and fix the error in the following code:
    let age = prompt('How old are you?');
    let nextAge = age + 1;
    console.log(`Next year you will be ${nextAge}`);
  12. Finish the code:
    let name = prompt('What is your name?');
    let age = Number(prompt('How old are you?'));
    let isInSixties;// finish the code so that it prints true if the age is in 60s
    console.log(`${name} is in sixties: ${isInSixties}`);
  13. What is the value of x?
    let x = 5;
    console.log(x++);
    console.log(x);
  14. What is the value of y?
    let y = 5;
    console.log(++y);
    console.log(y);
  15. What is x++ and x--?
  16. What is the difference between ++x and x++?
  17. If we try to declare variable without any value, what will be the value of the variable in the console?
  18. Show the example of equality operator.
  19. Show the example of not equal operator.
  20. What's going on when we try to add string and number?

About

Variables; Data Types (number, string, boolean, undefined, null); prompt; comparison and logical operators; type conversion

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published