JAVASCRIPT AND HTML CSS CODING PRACTICE EXERCISES Coding for Beginners (J. J. Tam) (Z-Library)

Author: J. J. Tam

HTML/CSS/JS

No Description

📄 File Format: PDF
💾 File Size: 797.6 KB
36
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
(This page has no text content)
📄 Page 2
JAVASCRIPT AND HTML CSS CODING PRACTICE EXERCISES           CODING FOR BEGINNERS JJ TAM
📄 Page 3
JAVASCRIPT FUNCTIONS – EXERCISES JAVASCRIPT: FIND THE FIRST NOT REPEATED CHARACTER JAVASCRIPT: FIND THE LONGEST WORD WITHIN A STRING JAVASCRIPT: COUNTS THE NUMBER OF VOWELS WITHIN A STRING JAVASCRIPT: CHECK A NUMBER IS PRIME OR NOT JAVASCRIPT: GET THE DATA TYPE JAVASCRIPT: FIND THE SECOND LOWEST AND SECOND GREATEST JAVASCRIPT BASICS CALCULATE MULTIPLICATION AND DIVISION CONVERT TEMPERATURES FIND THE LARGEST REVERSE A GIVEN STRING REPLACE EVERY CHARACTER CREATE A NEW STRING CONCATENATE TWO STRINGS MOVE LAST THREE CHARACTER COMPUTE THE SUM ADD TWO DIGITS CHECK WHETHER A GIVEN YEAR IS A LEAP CHECK GIVEN POSITIVE NUMBER CHECK A STRING STARTS WITH 'JAVA' CHECK TWO GIVEN INTEGER VALUES FIND A VALUE WHICH IS NEAREST TO 100 HTML CSS CODING PRACTICE CREATE A LINK CREATE A NOFOLLOW LINK OPEN A LINKED DOCUMENT CORRECT WAY TO WRITE ADDRESS
📄 Page 4
SPECIFY AN ALTERNATE TEXT CREATE AN HTML DOCUMENT CREATE AN HTML DOCUMENT TO ADD CONTROLS TO AN AUDIO WRITE BOLD TEXT USING HTML TAGS TO SPECIFY THE BASE URL ISOLATE A PART OF TEXT HTML CSS EXERCISE: HTML TABLE HTML CSS EXERCISE: CSS NAVIGATION BAR HTML CSS EXERCISE: HTML FORM HTML CSS EXERCISE: HTML5 AUDIO & VIDEO HTML CSS EXERCISE: CSS BUTTON HTML CSS EXERCISE: CREATE STITCHED LOOKS WITH CSS3 HTML CSS EXERCISE: CREATE CORNER RIBBON WITH CSS3 HTML CSS EXERCISE: BLURRY TEXT WITH CSS3 CREATE A SPEECH BUBBLE SHAPE WITH CSS3 SELECT ELEMENTS BY ATTRIBUTE SET STYLE FOR LINK, HOVER, ACTIVE AND VISITED STATES OF HYPERLINK HTML CSS EXERCISE: TYPE SELECTOR THIS IS HEADING ONE HTML CSS EXERCISE: DESCENDANT SELECTOR STYLE PLACEHOLDER TEXT SPECIFY WHERE TO SEND THE FORM-DATA SEND THE FORM-DATA SPECIFY WHERE TO DISPLAY SPECIFY A NAME FOR THE BUTTON SPECIFY THE TYPE OF BUTTON DRAW GRAPHICS, ON THE FLY, DEFINE A TABLE CAPTION SPECIFY THE COLUMN PROPERTIES
📄 Page 5
JAVASCRIPT CODING PRACTICE EXERCISES           CODING FOR BEGINNERS JJ TAM
📄 Page 6
JavaScript functions – Exercises JavaScript: Find the first not repeated character Sample arguments  : 'abacddbec' Expected output  : 'e' HTML CODE <!DOCTYPE html> <html> <head>   <meta charset="utf-8">   <title>find the first not repeated character.</title> </head> <body>   </body> </html>   JAVASCRIPT CODE function find_FirstNotRepeatedChar(str) {   var arra1 = str.split('');
📄 Page 7
  var result = '';   var ctr = 0;     for (var x = 0; x < arra1.length; x++) {     ctr = 0;       for (var y = 0; y < arra1.length; y++)     {       if (arra1[x] === arra1[y]) {         ctr+= 1;       }     }       if (ctr < 2) {       result = arra1[x];       break;     }   }   return result; } console.log(find_FirstNotRepeatedChar('abacddbec'));
📄 Page 8
OUTPUT e FLOWCHART
📄 Page 9
JavaScript: Find the longest word within a string Example string : 'Web Development Tutorial' Expected Output:  'Development' HTML CODE <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>Find the longest word within a string</title> </head> <body>   </body> </html>   JAVASCRIPT CODE function find_longest_word(str) {   var array1 = str.match(/\w[a-z]{0,}/gi);   var result = array1[0];  
📄 Page 10
  for(var x = 1 ; x < array1.length ; x++)   {     if(result.length < array1[x].length)     {     result = array1[x];     }   }   return result; } console.log(find_longest_word('Web Development Tutorial')); OUTPUT Development EXPLANATION Assume that str equals '@Web Production #Tutorial'. When a string is matched against a regular expression, the match() method is used to obtain the matches. As a result of str.match(/w[a-z]0,/gi), ["Web", "Development", "Tutorial"] will be returned. The for loop compares the length of each array element to the previous one and returns the longest string. The length property is a 32-bit unsigned integer that is always numerically greater than the array's highest index. Syntax -> arr.length
📄 Page 11
FLOWCHART
📄 Page 12
JavaScript: Counts the number of vowels within a string Example string : 'The quick brown fox' Expected Output:  5 HTML CODE <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>Counts the number of vowels within a string</title> </head> <body>   </body> </html> JAVASCRIPT CODE function vowel_count(str1) {   var vowel_list = 'aeiouAEIOU';   var vcount = 0;     for(var x = 0; x < str1.length ; x++)
📄 Page 13
  {     if (vowel_list.indexOf(str1[x]) !== -1)     {       vcount += 1;     }     }   return vcount; } console.log(vowel_count("The quick brown fox")); OUTPUT 5 EXPLANATION The indexOf() method returns the index of the first occurrence of the defined value within the calling String object, starting at fromIndex. If the value cannot be found, it returns -1. Syntax -> str.indexOf(searchValue[, fromIndex]) Parameters include: searchValue : A string that represents the value to be sought. fromIndex(Optional)-> The index at which the string's forward search should begin. Any integer can be used. If the condition (vowel list.indexOf(str1[x])!== -1) is met, the character(s) of the string will be counted as vowels. FLOWCHART
📄 Page 14
(This page has no text content)
📄 Page 15
JavaScript: Check a number is prime or not   HTML CODE <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>Check a number is prime or not</title> </head> <body>   </body> </html>
📄 Page 16
JAVASCRIPT CODE function test_prime(n) {     if (n===1)   {     return false;   }   else if(n === 2)   {     return true;   }else   {     for(var x = 2; x < n; x++)     {       if(n % x === 0)       {         return false;       }     }     return true;    } }   console.log(test_prime(37)); OUTPUT
📄 Page 17
True FLOWCHART
📄 Page 18
JavaScript: Get the data type We going to Create a JavaScript function which takes an argument and returns the type. Note six possible values: object, boolean, method, number, string, or undefined. HTML CODE <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>Detect JavaScript Data Types</title> </head> <body>   </body> </html> JAVASCRIPT CODE function detect_data_type(value) { var dtypes = [Function, RegExp, Number, String, Boolean, Object], x, len;   if (typeof value === "object" || typeof value === "function")
📄 Page 19
    {      for (x = 0, len = dtypes.length; x < len; x++)      {             if (value instanceof dtypes[x])             {                 return dtypes[x];             }       }     }       return typeof value; } console.log(detect_data_type(12)); console.log(detect_data_type('w3resource')); console.log(detect_data_type(false)); OUTPUT number string Boolean
📄 Page 20
JavaScript: Find the second lowest and second greatest numbers from an array HTML CODE <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>Find the second lowest and second greatest numbers from an array</title> </head> <body>   </body>
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List