0
0
Cypresstesting~10 mins

Node.js prerequisite in Cypress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check the installed Node.js version.

Cypress
const version = process.[1];
console.log(`Node.js version: ${version}`);
Drag options to blanks, or click blank then click option'
Aversion
Benv
Cplatform
Dargv
Attempts:
3 left
💡 Hint
Common Mistakes
Using process.env which gives environment variables, not version.
Using process.platform which gives OS platform, not Node.js version.
2fill in blank
medium

Complete the command to check Node.js version in terminal.

Cypress
node [1]
Drag options to blanks, or click blank then click option'
A--list
B--help
C--version
D--check
Attempts:
3 left
💡 Hint
Common Mistakes
Using --help which shows help info, not version.
Using --list which is not a valid option.
3fill in blank
hard

Fix the error in this Node.js script that prints version.

Cypress
console.log('Node.js version:', process.[1]);
Drag options to blanks, or click blank then click option'
Aver
Bversions
CversionNumber
Dversion
Attempts:
3 left
💡 Hint
Common Mistakes
Using process.versions which is an object, not a string.
Using made-up properties like ver or versionNumber.
4fill in blank
hard

Fill both blanks to create a script that checks if Node.js version starts with 'v14'.

Cypress
if (process.[1].[2]('v14')) {
  console.log('Node.js version is 14.x');
}
Drag options to blanks, or click blank then click option'
Aversion
BstartsWith
Cincludes
Dslice
Attempts:
3 left
💡 Hint
Common Mistakes
Using process.versions which is an object, not a string.
Using includes instead of startsWith which checks anywhere in string.
5fill in blank
hard

Fill all three blanks to create a script that extracts major Node.js version number as an integer.

Cypress
const versionString = process.[1];
const majorVersion = parseInt(versionString.[2](1, versionString.[3]('.', 1)));
console.log(`Major version: ${majorVersion}`);
Drag options to blanks, or click blank then click option'
Aversion
Bslice
CindexOf
Dsubstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using substring instead of slice which also works but here slice is expected.
Not removing the 'v' before parsing the number.
Using indexOf with wrong character.