





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
6.0 JAVASCRIPT QUESTIONS AND ANSWERS 2025
Typology: Exercises
1 / 9
This page cannot be seen from the preview
Don't miss anything!






45.How do you code a button.onclick event handler? document.getElementById("ButtonId").onclick = functionName; 46.For radio buttons, how do you get the text value of the control? document.getElementById("radioButtonId").value; 47.For radio buttons, how do you get the current checked status of the control? document.getElementById("radioButtonId").checked; 48.For checkboxes, how do you get the text value of the control? document.getElementById("checkboxId").value; 49.For checkboxes, how do you get the current checked status of the control? document.getElementById("checkboxId").checked; 50.For lists, how do you get the value or the currently selected item? document.getElementById("listId").value; 51.For a text area, how do you get the current value of the control? document.getElementById("textAreaId").value; 52.For a text area, how do you get the current character count for the control? var areaText = document.getElementById("textAreaId").value; var charCount = areaText.length; 53.For radio buttons, how do you set the current checked status of the control? document.getElementById("radioButtonId").checked = true; //Could also be false 54.For checkboxes, how do you set the current checked status of the control? document.getElementById("CheckboxId").checked = true; //Could also be false 55.For a text area, how do you set the current value of the control? document.getElementById("textAreaId").value = "Text Value"; 56.What are the available properties for the Number object? Number.MAX_VALUE Number.MIN_VALUE Number.POSITIVE_INFINITY Number.NEGATIVE_INFINITY Number.NaN
57.What are the 3 shortcuts for Number object properties? Infinity //Represents Number.POSITIVE_INFINITY
81.What String object method is used to get the character at a specified index position? charAt(position); 82.What String object method is used to concatenate multiple strings? concat(var1, var2, varN); 83.What String object method is used return the position of the first instance of a specified search string, starting from the specified index? indexOf(searchValue, startPosition); //If no startPosition is specified, the search begins from the start of the string 84.What String object method is used to return a new string that contains part of the original string from the specified start position? substring(startIndex); 85.What String object method is used to return a new string that contains part of the original string from the specified start position and up to but not including the specified stop index? substring(startIndex, stopIndex); //stopIndex is optional, if it is not specified, then it will go until the end of the string 86.What String object method returns a new string containing the value of the original string but in all upper case? toUpperCase(); 87.What String object method returns a new string containing the value of the original string but in all lower case? toLowerCase(); 88.What Math object method is used to return a given number raised to a given power? Math.pow(number, power); 89.What Math object method is used to return the square root of a given number? Math.sqrt(number); 90.What Math object method is used to return the highest value from a set of supplied numbers? Math.max(var1, var2, varN); 91.What Math object method is used to return the lowest value for a set of supplied numbers? Math.min(var1, var2, varN);
92.How do you create a new Date object? var dateObject = new Date(year, month, day, hours, minutes, seconds, milliseconds); 93.What is the format to create a new Date object from a string? var dateObject = new Date("11/22/2012 18:25:35"); 94.What Date object method is used to return the number of milliseconds since the start of GMT? getTime(); 95.What are the available get methods for a Date object? getTime(); getFullYear(); //Returns 4 digit year getMonth(); //Returns months, starts with 0 for January getDate(); // Returns day of the month getHours(); //Returns hours in the day getMinutes(); //Returns the minutes in the current hour getSeconds(); //Returns seconds in the current minute getMilliseconds(); //Returns milliseconds in the current second 96.What are the available set methods for a Date object? setFullYear(); //Sets 4 digit year setMonth(); //Sets months, starts with 0 for January setDate(); // Sets day of the month setHours(); //Sets hours in the day setMinutes(); //Sets the minutes in the current hour setSeconds(); //Sets seconds in the current minute setMilliseconds(); //Sets milliseconds in the current second 97.What Date object method is used to return a string containing the date and time? toString(); 98.What Date object method is used to return a string containing the date? toDateString(); 99.What Date object method is used to return a string containing the time? toTimeString();