chosen listlengths 2 2 | rejected listlengths 2 2 | score_chosen int64 6 9 | score_rejected int64 1 9 |
|---|---|---|---|
[
{
"content": "Write a recursive function in JS to traverse a multi-dimensional array and return the sum of all the elements in the array. However, the function should exclude any negative numbers from the sum.\n\nlet arr = [\n [1, 2, 3],\n [4, [-5, 6], [7, 8]],\n [9, [-10, [11, -12]]]\n];\n\nThe function sho... | [
{
"content": "Write a recursive function in JS to traverse a multi-dimensional array and return the sum of all the elements in the array. However, the function should exclude any negative numbers from the sum.\n\nlet arr = [\n [1, 2, 3],\n [4, [-5, 6], [7, 8]],\n [9, [-10, [11, -12]]]\n];\n\nThe function sho... | 6 | 6 |
[
{
"content": "Write a JavaScript program to display the Fibonacci sequence up to a given number n in the console.\n\nRequirements:\n- The program should take an input n from the user and display the Fibonacci sequence up to the nth number.\n- The program should handle invalid inputs gracefully and display an ap... | [
{
"content": "Write a JavaScript program to display the Fibonacci sequence up to a given number n in the console.\n\nRequirements:\n- The program should take an input n from the user and display the Fibonacci sequence up to the nth number.\n- The program should handle invalid inputs gracefully and display an ap... | 7 | 7 |
[
{
"content": "Write a JS code to detect peaks for an array of numbers. A peak is defined as an element that is greater than its adjacent elements. Modify the code to return an array of all the peak elements in the input array. Additionally, the code should now handle multiple peak elements that are adjacent to ... | [
{
"content": "Write a JS code to detect peaks for an array of numbers. A peak is defined as an element that is greater than its adjacent elements. Modify the code to return an array of all the peak elements in the input array. Additionally, the code should now handle multiple peak elements that are adjacent to ... | 9 | 9 |
[
{
"content": "Write a JavaScript function that takes in an array of numbers and returns two arrays: one containing all the prime numbers and one containing all the composite numbers.\n\n# Constraints:\n\n- The input array can have a maximum length of 10^6.\n- The input array will only contain positive integers.... | [
{
"content": "Write a JavaScript function that takes in an array of numbers and returns two arrays: one containing all the prime numbers and one containing all the composite numbers.\n\n# Constraints:\n\n- The input array can have a maximum length of 10^6.\n- The input array will only contain positive integers.... | 8 | 8 |
[
{
"content": "Create a JavaScript object to represent a library, with the following additional requirements:\n- The object should include a method to calculate the total value of all the books in the library, based on their individual prices and quantities.\n- The object should include a method to calculate the... | [
{
"content": "Create a JavaScript object to represent a library, with the following additional requirements:\n- The object should include a method to calculate the total value of all the books in the library, based on their individual prices and quantities.\n- The object should include a method to calculate the... | 9 | 9 |
[
{
"content": "Please write a JavaScript function to split an array into two equal parts, but the second part should be sorted in descending order. The function should have a time complexity of O(n log n) and a space complexity of O(n), where n is the length of the array.\n\nExample:\nInput: [5,6,7,8,9]\nOutput:... | [
{
"content": "Please write a JavaScript function to split an array into two equal parts, but the second part should be sorted in descending order. The function should have a time complexity of O(n log n) and a space complexity of O(n), where n is the length of the array.\n\nExample:\nInput: [5,6,7,8,9]\nOutput:... | 9 | 9 |
[
{
"content": "Write a JavaScript program to count the occurrences of each element in an array and return the elements in descending order based on their occurrence count. If there are elements with the same occurrence count, sort them alphabetically. The program should have a time complexity of O(n log n).",
... | [
{
"content": "Write a JavaScript program to count the occurrences of each element in an array and return the elements in descending order based on their occurrence count. If there are elements with the same occurrence count, sort them alphabetically. The program should have a time complexity of O(n log n).",
... | 7 | 7 |
[
{
"content": "Rewrite the code to export a JavaScript variable as a global variable, while also implementing a check to ensure that the variable is not overwritten if it already exists in the global scope. Additionally, modify the code to handle scenarios where the variable name is passed as a string, as a refe... | [
{
"content": "Rewrite the code to export a JavaScript variable as a global variable, while also implementing a check to ensure that the variable is not overwritten if it already exists in the global scope. Additionally, modify the code to handle scenarios where the variable name is passed as a string, as a refe... | 7 | 1 |
[
{
"content": "Generate a random UUID using Node.js. Additionally, ensure that the generated UUID is always in the format of xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where x is any hexadecimal digit and y is either 8, 9, A, B, C, D, E, or F. Furthermore, the generated UUID must be unique and cannot be generated aga... | [
{
"content": "Generate a random UUID using Node.js. Additionally, ensure that the generated UUID is always in the format of xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where x is any hexadecimal digit and y is either 8, 9, A, B, C, D, E, or F. Furthermore, the generated UUID must be unique and cannot be generated aga... | 9 | 2 |
[
{
"content": "Write a JavaScript code that calculates the factorial of a given number using recursion and returns the result.\n\nInput: 10\n\nNote: The input number will be a positive integer.\n\nExpected output: 3628800",
"role": "user"
},
{
"content": "Here is a JavaScript code that calculates the... | [
{
"content": "Write a JavaScript code that calculates the factorial of a given number using recursion and returns the result.\n\nInput: 10\n\nNote: The input number will be a positive integer.\n\nExpected output: 3628800",
"role": "user"
},
{
"content": "Here is a JavaScript code that calculates the... | 7 | 7 |
[
{
"content": "Write a JavaScript program to make an AJAX request to a specific API endpoint that returns a large dataset, parse the response efficiently, and display specific data from the response in a modal pop-up window. Additionally, handle any potential errors that may occur during the AJAX request, and op... | [
{
"content": "Write a JavaScript program to make an AJAX request to a specific API endpoint that returns a large dataset, parse the response efficiently, and display specific data from the response in a modal pop-up window. Additionally, handle any potential errors that may occur during the AJAX request, and op... | 7 | 7 |
[
{
"content": "Rewrite the following JavaScript code to add validation to an input field. The validation should ensure that the user's name is at least 5 characters long and does not contain any special characters or numbers. Additionally, the validation should also check if the name is a palindrome (i.e. it rea... | [
{
"content": "Rewrite the following JavaScript code to add validation to an input field. The validation should ensure that the user's name is at least 5 characters long and does not contain any special characters or numbers. Additionally, the validation should also check if the name is a palindrome (i.e. it rea... | 7 | 7 |
[
{
"content": "Please rewrite the given function in JavaScript with the following additional requirements:\n\n1. If both 'a' and 'b' are integers, return the result of dividing 'a' by 'b' as an integer. The time complexity should be O(1) and the space complexity should be O(1).\n2. If both 'a' and 'b' are floati... | [
{
"content": "Please rewrite the given function in JavaScript with the following additional requirements:\n\n1. If both 'a' and 'b' are integers, return the result of dividing 'a' by 'b' as an integer. The time complexity should be O(1) and the space complexity should be O(1).\n2. If both 'a' and 'b' are floati... | 6 | 6 |
[
{
"content": "Using the given array, write a Javascript program to sort the elements in descending order, without using any built-in sorting methods such as sort() or reverse(). Additionally, ensure that the program has a time complexity of O(n log n) or less. The program should also remove any duplicate elemen... | [
{
"content": "Using the given array, write a Javascript program to sort the elements in descending order, without using any built-in sorting methods such as sort() or reverse(). Additionally, ensure that the program has a time complexity of O(n log n) or less. The program should also remove any duplicate elemen... | 8 | 8 |
[
{
"content": "Define a function in JavaScript that takes an array of numbers as an argument and returns the smallest one.\n\nAdditional requirements:\n1. The function should handle arrays of any length, including empty arrays.\n2. If the array contains any non-numeric elements, the function should ignore them a... | [
{
"content": "Define a function in JavaScript that takes an array of numbers as an argument and returns the smallest one.\n\nAdditional requirements:\n1. The function should handle arrays of any length, including empty arrays.\n2. If the array contains any non-numeric elements, the function should ignore them a... | 7 | 7 |
[
{
"content": "Write a JavaScript function that takes a string argument and returns a count of all the times the letter 'a' appears in the string. Additionally, the function should also count the number of times the letter 'A' appears in the string, treating it as a different character than 'a'. The function sho... | [
{
"content": "Write a JavaScript function that takes a string argument and returns a count of all the times the letter 'a' appears in the string. Additionally, the function should also count the number of times the letter 'A' appears in the string, treating it as a different character than 'a'. The function sho... | 7 | 7 |
[
{
"content": "Write JavaScript code to output a pattern of stars in the shape of an isosceles right triangle. The code should allow the user to input the number of rows and columns for the triangle pattern, with the minimum input being 5. Additionally, the code should validate that the input is a positive odd i... | [
{
"content": "Write JavaScript code to output a pattern of stars in the shape of an isosceles right triangle. The code should allow the user to input the number of rows and columns for the triangle pattern, with the minimum input being 5. Additionally, the code should validate that the input is a positive odd i... | 9 | 9 |
[
{
"content": "Construct an object in JavaScript to model a car with make, model, year, color, price, and mileage as attributes. Implement a method to calculate the average fuel consumption of the car based on the mileage, fuel tank capacity, and fuel type (gasoline, diesel, hybrid, electric, etc.). Additionally... | [
{
"content": "Construct an object in JavaScript to model a car with make, model, year, color, price, and mileage as attributes. Implement a method to calculate the average fuel consumption of the car based on the mileage, fuel tank capacity, and fuel type (gasoline, diesel, hybrid, electric, etc.). Additionally... | 6 | 3 |
[
{
"content": "Please write a function in JavaScript that takes in a list of mixed data types (strings, numbers, booleans, etc.) and returns a new list containing only the numbers. The function should maintain the original order of the elements in the list and have a time complexity of O(n) and a space complexit... | [
{
"content": "Please write a function in JavaScript that takes in a list of mixed data types (strings, numbers, booleans, etc.) and returns a new list containing only the numbers. The function should maintain the original order of the elements in the list and have a time complexity of O(n) and a space complexit... | 9 | 9 |
[
{
"content": "Using JavaScript, write an algorithm to print the sum of all the prime numbers up to a given number n, where n is a positive integer less than or equal to 10,000. Your algorithm should have a time complexity of O(n log log n) and a space complexity of O(n).\n\nFurthermore, your algorithm should no... | [
{
"content": "Using JavaScript, write an algorithm to print the sum of all the prime numbers up to a given number n, where n is a positive integer less than or equal to 10,000. Your algorithm should have a time complexity of O(n log log n) and a space complexity of O(n).\n\nFurthermore, your algorithm should no... | 7 | 1 |
[
{
"content": "Create a JavaScript program that prompts the user to enter their full name, then checks if the name meets the following criteria: it must contain at least 5 words, each word must start with an uppercase letter, and there should be no numbers or special characters present. If the name does not meet... | [
{
"content": "Create a JavaScript program that prompts the user to enter their full name, then checks if the name meets the following criteria: it must contain at least 5 words, each word must start with an uppercase letter, and there should be no numbers or special characters present. If the name does not meet... | 9 | 2 |
[
{
"content": "Given a list of numbers and strings, create a function in JavaScript to return the sum of all its elements. However, the input list may contain negative numbers, decimals, and special characters. You must account for these scenarios and handle them appropriately in your solution. Additionally, the... | [
{
"content": "Given a list of numbers and strings, create a function in JavaScript to return the sum of all its elements. However, the input list may contain negative numbers, decimals, and special characters. You must account for these scenarios and handle them appropriately in your solution. Additionally, the... | 7 | 7 |
[
{
"content": "Create a JavaScript function that takes in an array of numbers and returns a new array where each number is rounded up to the nearest whole number. The function should not use any built-in JavaScript rounding functions and should implement the rounding logic manually.\n\nIn addition, implement the... | [
{
"content": "Create a JavaScript function that takes in an array of numbers and returns a new array where each number is rounded up to the nearest whole number. The function should not use any built-in JavaScript rounding functions and should implement the rounding logic manually.\n\nIn addition, implement the... | 6 | 1 |
[
{
"content": "Create a function in JavaScript to remove all occurrences of a specified value from an array. The function should have a time complexity of O(n) and should not use any built-in array methods or additional data structures. The input array can contain any type of elements, including nested arrays an... | [
{
"content": "Create a function in JavaScript to remove all occurrences of a specified value from an array. The function should have a time complexity of O(n) and should not use any built-in array methods or additional data structures. The input array can contain any type of elements, including nested arrays an... | 6 | 1 |
[
{
"content": "Create a JavaScript object to store information about an employee and include a method to calculate their monthly salary based on their hourly rate and number of hours worked. Additionally, include a method to calculate their annual salary, taking into account any bonuses or commissions they may h... | [
{
"content": "Create a JavaScript object to store information about an employee and include a method to calculate their monthly salary based on their hourly rate and number of hours worked. Additionally, include a method to calculate their annual salary, taking into account any bonuses or commissions they may h... | 6 | 6 |
[
{
"content": "Create a jQuery script to make all elements with a class name 'member' togglable. Additionally, the script should allow toggling the visibility of each 'member' element on click, and also keep track of the state of each 'member' element (i.e., whether it is currently visible or hidden). Implement ... | [
{
"content": "Create a jQuery script to make all elements with a class name 'member' togglable. Additionally, the script should allow toggling the visibility of each 'member' element on click, and also keep track of the state of each 'member' element (i.e., whether it is currently visible or hidden). Implement ... | 6 | 1 |
[
{
"content": "Find the sum of all numbers that are divisible by 3 in the following array of objects in JavaScript. However, you must use the reduce() method to calculate the sum instead of using a loop. Additionally, you should only include numbers that are greater than 10 and less than 100 in the calculation."... | [
{
"content": "Find the sum of all numbers that are divisible by 3 in the following array of objects in JavaScript. However, you must use the reduce() method to calculate the sum instead of using a loop. Additionally, you should only include numbers that are greater than 10 and less than 100 in the calculation."... | 6 | 6 |
[
{
"content": "Create an HTML form with five input fields, each with a unique validation requirement:\n1. A textbox that only allows alphanumeric characters, must be at least 8 characters long, should not contain any consecutive repeating characters, and cannot start or end with a number.\n2. A dropdown menu wit... | [
{
"content": "Create an HTML form with five input fields, each with a unique validation requirement:\n1. A textbox that only allows alphanumeric characters, must be at least 8 characters long, should not contain any consecutive repeating characters, and cannot start or end with a number.\n2. A dropdown menu wit... | 7 | 2 |
[
{
"content": "Write a JavaScript function to convert an object into a list of keys and values. However, if the object contains nested objects or arrays, include those nested keys and values as well. If a nested value is an object or array, represent it as a string in the format \"<type>:<value>\". Additionally,... | [
{
"content": "Write a JavaScript function to convert an object into a list of keys and values. However, if the object contains nested objects or arrays, include those nested keys and values as well. If a nested value is an object or array, represent it as a string in the format \"<type>:<value>\". Additionally,... | 7 | 7 |
[
{
"content": "Write a JavaScript code that creates a new array populated with the elements that exist in both of the given arrays, while also removing any duplicates. Additionally, the code should sort the elements in the new array in descending order. \n\nReference erroneous code:\n\n```\nfunction findCommonEl... | [
{
"content": "Write a JavaScript code that creates a new array populated with the elements that exist in both of the given arrays, while also removing any duplicates. Additionally, the code should sort the elements in the new array in descending order. \n\nReference erroneous code:\n\n```\nfunction findCommonEl... | 7 | 1 |
[
{
"content": "Define a variable in JavaScript to store a user's email address. Additionally, validate the email address to ensure it is in the correct format before storing it. Implement the validation to check for the following conditions:\n1. The email address should contain an '@' symbol.\n2. The domain name... | [
{
"content": "Define a variable in JavaScript to store a user's email address. Additionally, validate the email address to ensure it is in the correct format before storing it. Implement the validation to check for the following conditions:\n1. The email address should contain an '@' symbol.\n2. The domain name... | 8 | 4 |
[
{
"content": "Write a function in JavaScript that takes in two parameters: a string and a substring. The function should return a boolean value indicating whether or not the given string ends with the specified substring. The function should be case-sensitive and should also consider whitespace characters at th... | [
{
"content": "Write a function in JavaScript that takes in two parameters: a string and a substring. The function should return a boolean value indicating whether or not the given string ends with the specified substring. The function should be case-sensitive and should also consider whitespace characters at th... | 8 | 8 |
[
{
"content": "Write a JavaScript function to greet a user, given the user's name. However, the function should also check if the user's name is empty or only consists of whitespace characters. If so, the function should throw an error with a custom error message stating that the name is invalid.\n\nAdditionally... | [
{
"content": "Write a JavaScript function to greet a user, given the user's name. However, the function should also check if the user's name is empty or only consists of whitespace characters. If so, the function should throw an error with a custom error message stating that the name is invalid.\n\nAdditionally... | 6 | 6 |
[
{
"content": "Create a JavaScript program that reverses a given string without using the built-in reverse() method or any other string manipulation functions. The program should have a time complexity of O(n) and a space complexity of O(1).\n\nExample:\nInput: \"Hello\"\nOutput: \"olleH\"\n\nErroneous code: \n\... | [
{
"content": "Create a JavaScript program that reverses a given string without using the built-in reverse() method or any other string manipulation functions. The program should have a time complexity of O(n) and a space complexity of O(1).\n\nExample:\nInput: \"Hello\"\nOutput: \"olleH\"\n\nErroneous code: \n\... | 6 | 6 |
[
{
"content": "Write a script in JavaScript to print the first 50 prime Fibonacci numbers, where each prime Fibonacci number is greater than 100. Additionally, each prime Fibonacci number should also be a palindrome.",
"role": "user"
},
{
"content": "Here's a script in JavaScript that prints the firs... | [
{
"content": "Write a script in JavaScript to print the first 50 prime Fibonacci numbers, where each prime Fibonacci number is greater than 100. Additionally, each prime Fibonacci number should also be a palindrome.",
"role": "user"
},
{
"content": "Here's a script in JavaScript that prints the firs... | 9 | 9 |
[
{
"content": "Write a MongoDB query to find all documents in a collection whose field \"date\" is greater than or equal to today's date, whose field \"status\" is set to \"active\", and whose field \"category\" is set to either \"A\" or \"B\".",
"role": "user"
},
{
"content": "To find all documents ... | [
{
"content": "Write a MongoDB query to find all documents in a collection whose field \"date\" is greater than or equal to today's date, whose field \"status\" is set to \"active\", and whose field \"category\" is set to either \"A\" or \"B\".",
"role": "user"
},
{
"content": "To find all documents ... | 9 | 9 |
[
{
"content": "List all properties of a JavaScript object called ``person`` recursively. The object may have nested objects as properties, and all properties, including nested properties, should be listed. The solution should not use any built-in JavaScript functions such as `Object.keys()` or `Object.getOwnProp... | [
{
"content": "List all properties of a JavaScript object called ``person`` recursively. The object may have nested objects as properties, and all properties, including nested properties, should be listed. The solution should not use any built-in JavaScript functions such as `Object.keys()` or `Object.getOwnProp... | 7 | 7 |
[
{
"content": "Write a MongoDB query to find the top 5 roles with the highest number of users assigned, where each role must have both Permission 2 and Permission 3. The result should include the role name, the number of users assigned to each role, and the total number of users assigned to all roles.\n\nTo incr... | [
{
"content": "Write a MongoDB query to find the top 5 roles with the highest number of users assigned, where each role must have both Permission 2 and Permission 3. The result should include the role name, the number of users assigned to each role, and the total number of users assigned to all roles.\n\nTo incr... | 8 | 8 |
[
{
"content": "Create a complete JavaScript code that uses the fetch() API to make a POST request to a specified URL (e.g., https://api.example.com/endpoint) with the following payload:\n```\n{\n \"username\": \"john\",\n \"password\": \"secret\"\n}\n```\nThe code should handle the following scenarios:\n1. Net... | [
{
"content": "Create a complete JavaScript code that uses the fetch() API to make a POST request to a specified URL (e.g., https://api.example.com/endpoint) with the following payload:\n```\n{\n \"username\": \"john\",\n \"password\": \"secret\"\n}\n```\nThe code should handle the following scenarios:\n1. Net... | 7 | 7 |
[
{
"content": "Create a Date object containing the current date and time in the local time zone, add 2 hours and 30 minutes to it, and then convert it to a string in the format \"YYYY-MM-DDTHH:MM:SSZ\". Additionally, handle any potential errors that may occur during the conversion process.",
"role": "user"
... | [
{
"content": "Create a Date object containing the current date and time in the local time zone, add 2 hours and 30 minutes to it, and then convert it to a string in the format \"YYYY-MM-DDTHH:MM:SSZ\". Additionally, handle any potential errors that may occur during the conversion process.",
"role": "user"
... | 7 | 2 |
[
{
"content": "Design a function in JavaScript that takes two parameters and performs a multiplication between them. The function should also check if either of the parameters is not a number, and if so, it should throw an error with a descriptive message. Additionally, the function should round the result to th... | [
{
"content": "Design a function in JavaScript that takes two parameters and performs a multiplication between them. The function should also check if either of the parameters is not a number, and if so, it should throw an error with a descriptive message. Additionally, the function should round the result to th... | 9 | 9 |
[
{
"content": "Write a function in JavaScript to check whether a given positive integer is a prime number. The function should include error handling to ensure that only positive integers are accepted as input. Additionally, the function should use a different approach (e.g. Miller-Rabin primality test) to deter... | [
{
"content": "Write a function in JavaScript to check whether a given positive integer is a prime number. The function should include error handling to ensure that only positive integers are accepted as input. Additionally, the function should use a different approach (e.g. Miller-Rabin primality test) to deter... | 8 | 2 |
[
{
"content": "Given an array of integers, write a JavaScript function that removes all duplicate items from the array. The function should return the modified array without altering the order of the remaining elements.\n\nExample:\n\nInput: [20, 30, 20, 15, 30, 45]\nOutput: [20, 30, 15, 45]\n\nYou should not us... | [
{
"content": "Given an array of integers, write a JavaScript function that removes all duplicate items from the array. The function should return the modified array without altering the order of the remaining elements.\n\nExample:\n\nInput: [20, 30, 20, 15, 30, 45]\nOutput: [20, 30, 15, 45]\n\nYou should not us... | 6 | 3 |
[
{
"content": "Create an event handler for a double click event that updates a specific text field only when the mouse cursor is within a certain region on the screen. Additionally, the text field should only be updated if the double click occurs within 3 seconds of the first click, and the specific region on th... | [
{
"content": "Create an event handler for a double click event that updates a specific text field only when the mouse cursor is within a certain region on the screen. Additionally, the text field should only be updated if the double click occurs within 3 seconds of the first click, and the specific region on th... | 7 | 3 |
[
{
"content": "Design a function in JavaScript to return the index of the second last positive element in an array, but with the added constraints that you cannot use the built-in array methods indexOf() or lastIndexOf(), and you must also account for the possibility that the array may contain non-integer elemen... | [
{
"content": "Design a function in JavaScript to return the index of the second last positive element in an array, but with the added constraints that you cannot use the built-in array methods indexOf() or lastIndexOf(), and you must also account for the possibility that the array may contain non-integer elemen... | 9 | 9 |
[
{
"content": "Create a Node.js script to read from a MongoDB database and perform a complex aggregation query. The script should implement a caching mechanism to store the results of the query for faster access. The caching mechanism should automatically invalidate the cache after a certain time period or when ... | [
{
"content": "Create a Node.js script to read from a MongoDB database and perform a complex aggregation query. The script should implement a caching mechanism to store the results of the query for faster access. The caching mechanism should automatically invalidate the cache after a certain time period or when ... | 6 | 6 |
[
{
"content": "Write a function in JavaScript to reorder the given list in ascending order, using the QuickSort algorithm. The list may contain duplicate elements and can have a maximum length of 10000. The function should have a time complexity of O(n log n) and should not use any built-in sorting functions or ... | [
{
"content": "Write a function in JavaScript to reorder the given list in ascending order, using the QuickSort algorithm. The list may contain duplicate elements and can have a maximum length of 10000. The function should have a time complexity of O(n log n) and should not use any built-in sorting functions or ... | 7 | 2 |
[
{
"content": "Construct a React component to show a blog post. The component should include a like button that updates the number of likes when clicked. The blog post should also display the author's name and the date it was published. Additionally, the component should have a comment section where users can le... | [
{
"content": "Construct a React component to show a blog post. The component should include a like button that updates the number of likes when clicked. The blog post should also display the author's name and the date it was published. Additionally, the component should have a comment section where users can le... | 7 | 7 |
[
{
"content": "Given a dictionary containing student information, produce an HTML table with the following additional constraints: \n- The table must have a border of 1 pixel.\n- The table headers (Field and Value) must have a background color of light gray.\n- Each row in the table must have a background color ... | [
{
"content": "Given a dictionary containing student information, produce an HTML table with the following additional constraints: \n- The table must have a border of 1 pixel.\n- The table headers (Field and Value) must have a background color of light gray.\n- Each row in the table must have a background color ... | 7 | 3 |
[
{
"content": "Write a JavaScript function that takes an input string and replaces all occurrences of the letter 'e' with an asterisk, but only if it is followed by the letter 'o'. Otherwise, leave the letter 'e' unchanged.\n\nConstraints:\n- The input string can have a maximum length of 10^6 characters.\n- The ... | [
{
"content": "Write a JavaScript function that takes an input string and replaces all occurrences of the letter 'e' with an asterisk, but only if it is followed by the letter 'o'. Otherwise, leave the letter 'e' unchanged.\n\nConstraints:\n- The input string can have a maximum length of 10^6 characters.\n- The ... | 8 | 8 |
[
{
"content": "Design a JavaScript class for a bank account with two private variables, account_balance and transactions. The class should have four public functions: deposit(amount), withdraw(amount), getBalance(), and getTransactionHistory().\n\nThe deposit(amount) function should add the given amount to the a... | [
{
"content": "Design a JavaScript class for a bank account with two private variables, account_balance and transactions. The class should have four public functions: deposit(amount), withdraw(amount), getBalance(), and getTransactionHistory().\n\nThe deposit(amount) function should add the given amount to the a... | 8 | 8 |
[
{
"content": "Create a web page that displays a list of 1000 items. Each item should have a clickable link that opens in a new tab and has a custom tooltip text when hovered over. The list should be dynamically generated using JavaScript and should have a search bar at the top that allows users to filter the it... | [
{
"content": "Create a web page that displays a list of 1000 items. Each item should have a clickable link that opens in a new tab and has a custom tooltip text when hovered over. The list should be dynamically generated using JavaScript and should have a search bar at the top that allows users to filter the it... | 8 | 8 |
[
{
"content": "Create a function to calculate the sum of the first n prime numbers less than 1000, where n is a positive integer not exceeding 100, and the function should have a time complexity of O(n^2) or better. Use JavaScript.",
"role": "user"
},
{
"content": "Here's an example of a function tha... | [
{
"content": "Create a function to calculate the sum of the first n prime numbers less than 1000, where n is a positive integer not exceeding 100, and the function should have a time complexity of O(n^2) or better. Use JavaScript.",
"role": "user"
},
{
"content": "Here's an example of a function tha... | 7 | 7 |
[
{
"content": "Create a JavaScript object with three properties: a number property, a string property, and an array property. The array property should contain a list of objects, each with a number and string property. Add a method to the object that takes in two parameters (a number and a string) and returns th... | [
{
"content": "Create a JavaScript object with three properties: a number property, a string property, and an array property. The array property should contain a list of objects, each with a number and string property. Add a method to the object that takes in two parameters (a number and a string) and returns th... | 9 | 9 |
[
{
"content": "Create a JavaScript object property with a string value that is encrypted using a custom encryption algorithm. The encryption algorithm should incorporate a random salt value and a key derived from a password. The encrypted string should be stored in the property as a hexadecimal string. The passw... | [
{
"content": "Create a JavaScript object property with a string value that is encrypted using a custom encryption algorithm. The encryption algorithm should incorporate a random salt value and a key derived from a password. The encrypted string should be stored in the property as a hexadecimal string. The passw... | 8 | 1 |
[
{
"content": "Write a JavaScript function that takes in an array of positive integers and a number between 1 and 100 (inclusive) as arguments. The function should return the array sorted in ascending order with the number inserted in the right position. The array should not contain any duplicate elements. Addit... | [
{
"content": "Write a JavaScript function that takes in an array of positive integers and a number between 1 and 100 (inclusive) as arguments. The function should return the array sorted in ascending order with the number inserted in the right position. The array should not contain any duplicate elements. Addit... | 6 | 6 |
[
{
"content": "Write a JavaScript program that takes a specific timezone as input and displays the current date and time in the format \"DD/MM/YYYY HH:MM:SS\". The program should also consider daylight saving time adjustments, if applicable.\n\nTo solve this problem, you can follow these steps:\n1. Create a func... | [
{
"content": "Write a JavaScript program that takes a specific timezone as input and displays the current date and time in the format \"DD/MM/YYYY HH:MM:SS\". The program should also consider daylight saving time adjustments, if applicable.\n\nTo solve this problem, you can follow these steps:\n1. Create a func... | 6 | 6 |
[
{
"content": "Please implement a JavaScript function that takes in two strings as arguments and returns true if the first string is present in the second string, and false otherwise. The function should be case-sensitive.\n\nExample:\n```javascript\nfunction isSubstring(substring, string) {\n if (substring.l... | [
{
"content": "Please implement a JavaScript function that takes in two strings as arguments and returns true if the first string is present in the second string, and false otherwise. The function should be case-sensitive.\n\nExample:\n```javascript\nfunction isSubstring(substring, string) {\n if (substring.l... | 9 | 9 |
[
{
"content": "Write a JavaScript function that takes in an array and returns an array of objects containing the original array elements and their frequency. The function should also sort the objects in the output array based on the frequency of each element in descending order. Additionally, the function should... | [
{
"content": "Write a JavaScript function that takes in an array and returns an array of objects containing the original array elements and their frequency. The function should also sort the objects in the output array based on the frequency of each element in descending order. Additionally, the function should... | 6 | 6 |
[
{
"content": "Create an array of five different colors in JavaScript. Each color must be randomly selected from a predefined list of at least 15 colors. Additionally, the colors in the array must be sorted in alphabetical order and should not include any duplicate colors.",
"role": "user"
},
{
"cont... | [
{
"content": "Create an array of five different colors in JavaScript. Each color must be randomly selected from a predefined list of at least 15 colors. Additionally, the colors in the array must be sorted in alphabetical order and should not include any duplicate colors.",
"role": "user"
},
{
"cont... | 6 | 3 |
[
{
"content": "Create a boolean expression in JavaScript, which returns false if a variable named \"result\" is an empty string or a string consisting of only whitespace characters. Additionally, the solution should also return false if the string contains any special characters. The solution should have a time ... | [
{
"content": "Create a boolean expression in JavaScript, which returns false if a variable named \"result\" is an empty string or a string consisting of only whitespace characters. Additionally, the solution should also return false if the string contains any special characters. The solution should have a time ... | 7 | 7 |
[
{
"content": "Write a filter function in JavaScript to return elements from an array of strings which start with the letter \"a\" and end with the letter \"t\". The function should also ignore case sensitivity, so it should match words starting with \"A\" or \"a\" and ending with \"T\" or \"t\". Additionally, t... | [
{
"content": "Write a filter function in JavaScript to return elements from an array of strings which start with the letter \"a\" and end with the letter \"t\". The function should also ignore case sensitivity, so it should match words starting with \"A\" or \"a\" and ending with \"T\" or \"t\". Additionally, t... | 8 | 8 |
[
{
"content": "Generate a JavaScript program that asks the user to input a list of numbers separated by commas. The program should then check each number in the list and display a message indicating whether it is greater than 10 and divisible by both 3 and 5, greater than 10 and divisible by only 3, greater than... | [
{
"content": "Generate a JavaScript program that asks the user to input a list of numbers separated by commas. The program should then check each number in the list and display a message indicating whether it is greater than 10 and divisible by both 3 and 5, greater than 10 and divisible by only 3, greater than... | 9 | 9 |
[
{
"content": "Create a function in JavaScript that takes in an array of strings and returns a new array with all the elements in reverse order. However, you are not allowed to use any built-in array methods such as `reverse()` or `sort()`. The function should have a time complexity of O(n), where n is the lengt... | [
{
"content": "Create a function in JavaScript that takes in an array of strings and returns a new array with all the elements in reverse order. However, you are not allowed to use any built-in array methods such as `reverse()` or `sort()`. The function should have a time complexity of O(n), where n is the lengt... | 7 | 7 |
[
{
"content": "Given an array of integers, write a program to find and print the sum of all the prime numbers in the array. The program should also calculate and print the average of all the prime numbers found, rounded to two decimal places. Additionally, the program should output the index position of the firs... | [
{
"content": "Given an array of integers, write a program to find and print the sum of all the prime numbers in the array. The program should also calculate and print the average of all the prime numbers found, rounded to two decimal places. Additionally, the program should output the index position of the firs... | 8 | 1 |
[
{
"content": "Write a JavaScript code for the following action: When the user types \"I'm hungry!\" in the text box and presses the enter key, the system will check if the user has entered a valid number in the adjacent number input field. \n\nIf the entered number is greater than or equal to 5, the system will... | [
{
"content": "Write a JavaScript code for the following action: When the user types \"I'm hungry!\" in the text box and presses the enter key, the system will check if the user has entered a valid number in the adjacent number input field. \n\nIf the entered number is greater than or equal to 5, the system will... | 9 | 9 |
[
{
"content": "Write a JavaScript function that takes a positive integer as input and returns true if it is a prime number, and false otherwise. The function should also handle and display an error message if the input is not a positive integer.\n\nTo determine if a number is prime, the function should follow th... | [
{
"content": "Write a JavaScript function that takes a positive integer as input and returns true if it is a prime number, and false otherwise. The function should also handle and display an error message if the input is not a positive integer.\n\nTo determine if a number is prime, the function should follow th... | 6 | 3 |
[
{
"content": "Construct a While Loop in JavaScript that iterates from 100 to 1000 and prints only the prime numbers that are also palindromic.",
"role": "user"
},
{
"content": "Here is a code snippet that constructs a while loop in JavaScript to iterate from 100 to 1000, and prints only the prime nu... | [
{
"content": "Construct a While Loop in JavaScript that iterates from 100 to 1000 and prints only the prime numbers that are also palindromic.",
"role": "user"
},
{
"content": "Here is a code snippet that constructs a while loop in JavaScript to iterate from 100 to 1000, and prints only the prime nu... | 8 | 8 |
[
{
"content": "Utilizing the regular expression [a-zA-Z0-9]+, construct a JavaScript script to find all matching patterns from the given string. Additionally, handle cases where the matching patterns must be surrounded by specific characters - '(' and ')'. The time complexity should be O(n), where n is the lengt... | [
{
"content": "Utilizing the regular expression [a-zA-Z0-9]+, construct a JavaScript script to find all matching patterns from the given string. Additionally, handle cases where the matching patterns must be surrounded by specific characters - '(' and ')'. The time complexity should be O(n), where n is the lengt... | 6 | 1 |
[
{
"content": "Create a JavaScript function that takes in an array of integers and finds the third smallest distinct number. If there are not enough distinct numbers in the array to find the third smallest, the function should return undefined. \n\nThe function should consider negative numbers and zero as well.\... | [
{
"content": "Create a JavaScript function that takes in an array of integers and finds the third smallest distinct number. If there are not enough distinct numbers in the array to find the third smallest, the function should return undefined. \n\nThe function should consider negative numbers and zero as well.\... | 9 | 1 |
[
{
"content": "Suggest a way of preserving the order of elements in a JavaScript array using a set data structure, while also achieving a time complexity of O(1) for both insertion and retrieval operations. Additionally, provide a piece of erroneous code that attempts to achieve this but fails to maintain the or... | [
{
"content": "Suggest a way of preserving the order of elements in a JavaScript array using a set data structure, while also achieving a time complexity of O(1) for both insertion and retrieval operations. Additionally, provide a piece of erroneous code that attempts to achieve this but fails to maintain the or... | 9 | 9 |
[
{
"content": "Write a JavaScript program to create an array of the first 1000 Fibonacci numbers that are prime and have a prime index. Additionally, the program should calculate the sum of all the prime Fibonacci numbers in the array. The program should be optimized to have a time complexity of O(n), where n is... | [
{
"content": "Write a JavaScript program to create an array of the first 1000 Fibonacci numbers that are prime and have a prime index. Additionally, the program should calculate the sum of all the prime Fibonacci numbers in the array. The program should be optimized to have a time complexity of O(n), where n is... | 8 | 8 |
[
{
"content": "Create an HTML form with a submit button that will trigger an alert message on clicking the button. Additionally, include client-side form validation to ensure that the form cannot be submitted unless all required fields are filled in correctly. The form should have the following requirements:\n\n... | [
{
"content": "Create an HTML form with a submit button that will trigger an alert message on clicking the button. Additionally, include client-side form validation to ensure that the form cannot be submitted unless all required fields are filled in correctly. The form should have the following requirements:\n\n... | 7 | 7 |
[
{
"content": "Write a JavaScript function that generates a random number between 1 and 100. The generated number should not be divisible by any prime number less than or equal to ",
"role": "user"
},
{
"content": "Here's a JavaScript function that generates a random number between 1 and 100, excludi... | [
{
"content": "Write a JavaScript function that generates a random number between 1 and 100. The generated number should not be divisible by any prime number less than or equal to ",
"role": "user"
},
{
"content": "Here's a JavaScript function that generates a random number between 1 and 100, excludi... | 9 | 3 |
[
{
"content": "Using JavaScript, create a function to find the longest word in a string, while ignoring any punctuation marks or special characters. Additionally, the function should return an array containing all the words that have the same length as the longest word. However, you are not allowed to use built-... | [
{
"content": "Using JavaScript, create a function to find the longest word in a string, while ignoring any punctuation marks or special characters. Additionally, the function should return an array containing all the words that have the same length as the longest word. However, you are not allowed to use built-... | 6 | 6 |
[
{
"content": "Write a JavaScript function that takes an array of numbers and returns the sum of all the numbers in the array. The function should also check if the array is sorted in ascending order and if not, it should sort the array before calculating the sum. Additionally, the function should ignore any neg... | [
{
"content": "Write a JavaScript function that takes an array of numbers and returns the sum of all the numbers in the array. The function should also check if the array is sorted in ascending order and if not, it should sort the array before calculating the sum. Additionally, the function should ignore any neg... | 8 | 3 |
[
{
"content": "Please write a function that takes in a nested array and returns a flattened version of the array. The function should handle arrays of any depth and size.\n\nExample:\n\nInput:\n[1, [2], 3, [4, [5, 6], 7]]\n\nOutput:\n[1, 2, 3, 4, 5, 6, 7]\n\nNote: Your function should not use any built-in array ... | [
{
"content": "Please write a function that takes in a nested array and returns a flattened version of the array. The function should handle arrays of any depth and size.\n\nExample:\n\nInput:\n[1, [2], 3, [4, [5, 6], 7]]\n\nOutput:\n[1, 2, 3, 4, 5, 6, 7]\n\nNote: Your function should not use any built-in array ... | 8 | 3 |
[
{
"content": "Write a JavaScript function that takes two parameters: a starting number and an ending number. The function should return a new array containing the squared values of all odd numbers within the range (inclusive). The function should have a time complexity of O(n), where n is the number of elements... | [
{
"content": "Write a JavaScript function that takes two parameters: a starting number and an ending number. The function should return a new array containing the squared values of all odd numbers within the range (inclusive). The function should have a time complexity of O(n), where n is the number of elements... | 7 | 7 |
[
{
"content": "Create a JavaScript function that will loop through an array of numbers and calculate the sum of all the elements. However, you are not allowed to use the '+' operator or any built-in functions for addition, and you cannot use any temporary variables. The function should return the sum. The time c... | [
{
"content": "Create a JavaScript function that will loop through an array of numbers and calculate the sum of all the elements. However, you are not allowed to use the '+' operator or any built-in functions for addition, and you cannot use any temporary variables. The function should return the sum. The time c... | 6 | 4 |
[
{
"content": "Edit this HTML form to make sure that the input data is validated. The form should include the following fields and validation criteria:\n\n1. Name field:\n - Only accept alphabetic characters.\n - Maximum length of 50 characters.\n - Required field.\n\n2. Email field:\n - Valid email form... | [
{
"content": "Edit this HTML form to make sure that the input data is validated. The form should include the following fields and validation criteria:\n\n1. Name field:\n - Only accept alphabetic characters.\n - Maximum length of 50 characters.\n - Required field.\n\n2. Email field:\n - Valid email form... | 8 | 8 |
[
{
"content": "Write a JavaScript function to check if all elements of an array of numbers are distinct and non-negative. The function should also handle arrays that contain both numbers and strings. The function should return true only if all numbers in the array are distinct, greater than or equal to zero, and... | [
{
"content": "Write a JavaScript function to check if all elements of an array of numbers are distinct and non-negative. The function should also handle arrays that contain both numbers and strings. The function should return true only if all numbers in the array are distinct, greater than or equal to zero, and... | 9 | 2 |
[
{
"content": "Create a JavaScript function to format a date object into day, month, and year, while also accounting for different time zones and displaying the date in both 12-hour and 24-hour formats. Additionally, the function should be able to handle dates in different calendars (such as Gregorian, Julian, H... | [
{
"content": "Create a JavaScript function to format a date object into day, month, and year, while also accounting for different time zones and displaying the date in both 12-hour and 24-hour formats. Additionally, the function should be able to handle dates in different calendars (such as Gregorian, Julian, H... | 6 | 2 |
[
{
"content": "Create a JavaScript program that takes an array of numbers and returns an object with three properties: \"positiveSum\", \"negativeSum\", and \"zeroSum\". \n\nThe \"positiveSum\" property should represent the sum of the squares of all the unique positive numbers in the array. Duplicate positive nu... | [
{
"content": "Create a JavaScript program that takes an array of numbers and returns an object with three properties: \"positiveSum\", \"negativeSum\", and \"zeroSum\". \n\nThe \"positiveSum\" property should represent the sum of the squares of all the unique positive numbers in the array. Duplicate positive nu... | 7 | 7 |
[
{
"content": "Create a JavaScript program that calculates the total price of items in a shopping cart, including discounts.\n\n## Requirements:\n1. The program should take an array of objects as a parameter. Each object represents an item in the shopping cart and has the following properties:\n - name: a stri... | [
{
"content": "Create a JavaScript program that calculates the total price of items in a shopping cart, including discounts.\n\n## Requirements:\n1. The program should take an array of objects as a parameter. Each object represents an item in the shopping cart and has the following properties:\n - name: a stri... | 7 | 3 |
[
{
"content": "Write a function in JavaScript that adds a table row to an HTML table, but with the following requirements:\n\n1. The function should take three parameters: the HTML table element, an array of values for each cell in the new row, and an optional callback function.\n2. The new row should be added t... | [
{
"content": "Write a function in JavaScript that adds a table row to an HTML table, but with the following requirements:\n\n1. The function should take three parameters: the HTML table element, an array of values for each cell in the new row, and an optional callback function.\n2. The new row should be added t... | 8 | 4 |
[
{
"content": "Convert the following Java code into JavaScript and handle the case where the input array is empty.\n\npublic static int max(int[] array){\n if(array.length == 0){\n throw new Error(\"Empty array\");\n }\n int max = array[0];\n for(int i=1; i<array.length; i++){\n if(arra... | [
{
"content": "Convert the following Java code into JavaScript and handle the case where the input array is empty.\n\npublic static int max(int[] array){\n if(array.length == 0){\n throw new Error(\"Empty array\");\n }\n int max = array[0];\n for(int i=1; i<array.length; i++){\n if(arra... | 9 | 9 |
[
{
"content": "Formulate a query in MongoDB to find records with a specific field having an array containing a certain value. Additionally, the query should only return documents where the array contains the value more than once, and the value itself is not the first or last element in the array. The query shoul... | [
{
"content": "Formulate a query in MongoDB to find records with a specific field having an array containing a certain value. Additionally, the query should only return documents where the array contains the value more than once, and the value itself is not the first or last element in the array. The query shoul... | 6 | 6 |
[
{
"content": "Write a script in JavaScript to calculate the median temperature from a given array of temperatures, but exclude any temperatures below 0 degrees Celsius. Additionally, round the median temperature to the nearest whole number before returning the result.\n\nNote: The median temperature is the midd... | [
{
"content": "Write a script in JavaScript to calculate the median temperature from a given array of temperatures, but exclude any temperatures below 0 degrees Celsius. Additionally, round the median temperature to the nearest whole number before returning the result.\n\nNote: The median temperature is the midd... | 9 | 9 |
[
{
"content": "Develop JavaScript code to find the nth Fibonacci number within a time complexity of O(log n), without using any loops or recursion.",
"role": "user"
},
{
"content": "To find the nth Fibonacci number without using loops or recursion and with a time complexity of O(log n), we can use ma... | [
{
"content": "Develop JavaScript code to find the nth Fibonacci number within a time complexity of O(log n), without using any loops or recursion.",
"role": "user"
},
{
"content": "To find the nth Fibonacci number without using loops or recursion and with a time complexity of O(log n), we can use ma... | 8 | 1 |
[
{
"content": "Write JavaScript code to print the Fibonacci sequence, but instead of starting with 0 and 1, start with a different pair of numbers provided as input. Additionally, implement a recursive solution to calculate the nth Fibonacci number. \n\nYour code should handle edge cases, such as invalid input (... | [
{
"content": "Write JavaScript code to print the Fibonacci sequence, but instead of starting with 0 and 1, start with a different pair of numbers provided as input. Additionally, implement a recursive solution to calculate the nth Fibonacci number. \n\nYour code should handle edge cases, such as invalid input (... | 9 | 9 |
[
{
"content": "Design a function in JavaScript to find the sum of the first n prime numbers. The function should check if the input is a positive integer and return an error message if it is not. The input should also be validated to ensure that it is within the range of 1 to 1000, inclusive. If the input is out... | [
{
"content": "Design a function in JavaScript to find the sum of the first n prime numbers. The function should check if the input is a positive integer and return an error message if it is not. The input should also be validated to ensure that it is within the range of 1 to 1000, inclusive. If the input is out... | 8 | 1 |
[
{
"content": "Using the given array, create a JavaScript function that returns the sum of all elements in the array. The function should only iterate through the array once and must have a time complexity of O(n). Additionally, the function should not use any built-in array methods or operators such as reduce, ... | [
{
"content": "Using the given array, create a JavaScript function that returns the sum of all elements in the array. The function should only iterate through the array once and must have a time complexity of O(n). Additionally, the function should not use any built-in array methods or operators such as reduce, ... | 6 | 6 |
[
{
"content": "Create a function in JavaScript that takes in an array of numbers and returns the sum of all unique pairs of numbers in the array that add up to a given target number.\n\nThe function should have a time complexity of O(n log n), where n is the length of the array. Additionally, the function should... | [
{
"content": "Create a function in JavaScript that takes in an array of numbers and returns the sum of all unique pairs of numbers in the array that add up to a given target number.\n\nThe function should have a time complexity of O(n log n), where n is the length of the array. Additionally, the function should... | 9 | 4 |
[
{
"content": "Create a JavaScript function that takes two strings as parameters and checks if the first one contains the second one. The function should be case-sensitive and should return true only if the second string is found as a whole word within the first string. Additionally, the function should handle s... | [
{
"content": "Create a JavaScript function that takes two strings as parameters and checks if the first one contains the second one. The function should be case-sensitive and should return true only if the second string is found as a whole word within the first string. Additionally, the function should handle s... | 6 | 3 |
[
{
"content": "Write a JavaScript code to read the content of a given URL, validate its format using regular expressions, and store it in a MongoDB database. The code should also check for the presence of specific keywords within the content and add appropriate tags to the entries in the database. The data shoul... | [
{
"content": "Write a JavaScript code to read the content of a given URL, validate its format using regular expressions, and store it in a MongoDB database. The code should also check for the presence of specific keywords within the content and add appropriate tags to the entries in the database. The data shoul... | 9 | 9 |
[
{
"content": "Write a JavaScript program to sort an array of strings according to the length of each string. The program should also handle strings that contain both uppercase and lowercase letters. Additionally, the program should ignore any strings that contain numbers or special characters. Finally, the prog... | [
{
"content": "Write a JavaScript program to sort an array of strings according to the length of each string. The program should also handle strings that contain both uppercase and lowercase letters. Additionally, the program should ignore any strings that contain numbers or special characters. Finally, the prog... | 6 | 6 |
[
{
"content": "How can we remove duplicates from an array in JavaScript without using any built-in array methods, additional data structures, or nested loops, while maintaining the original order of elements and achieving a time complexity of O(n)?",
"role": "user"
},
{
"content": "To remove duplicat... | [
{
"content": "How can we remove duplicates from an array in JavaScript without using any built-in array methods, additional data structures, or nested loops, while maintaining the original order of elements and achieving a time complexity of O(n)?",
"role": "user"
},
{
"content": "To remove duplicat... | 7 | 7 |
[
{
"content": "Write a sliding window algorithm in JavaScript to collect all the subarrays with size k from an array of size n. In the resulting subarray, each element should be raised to the power of 4. Return the sum of all the subarrays.\n\nlet input = [1, 2, 3, 4, 5, 6, 7, 8];\nlet K = 3;\n\nExample:\nInput:... | [
{
"content": "Write a sliding window algorithm in JavaScript to collect all the subarrays with size k from an array of size n. In the resulting subarray, each element should be raised to the power of 4. Return the sum of all the subarrays.\n\nlet input = [1, 2, 3, 4, 5, 6, 7, 8];\nlet K = 3;\n\nExample:\nInput:... | 8 | 8 |
[
{
"content": "Write an AngularJS controller to set the \"page\" variable to be the same as the page parameter passed in the URL, but only if the page parameter is a positive integer greater than 1000 and less than 9999. Additionally, the controller should validate that the page parameter is provided in the URL ... | [
{
"content": "Write an AngularJS controller to set the \"page\" variable to be the same as the page parameter passed in the URL, but only if the page parameter is a positive integer greater than 1000 and less than 9999. Additionally, the controller should validate that the page parameter is provided in the URL ... | 8 | 8 |
[
{
"content": "Write a JavaScript function to modify a given list and convert all elements to lowercase. The function should not use any built-in JavaScript methods or libraries for string manipulation, and it should only use a constant amount of extra space. The time complexity of the function should be O(n), w... | [
{
"content": "Write a JavaScript function to modify a given list and convert all elements to lowercase. The function should not use any built-in JavaScript methods or libraries for string manipulation, and it should only use a constant amount of extra space. The time complexity of the function should be O(n), w... | 8 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.