Dataset Viewer
Auto-converted to Parquet Duplicate
chosen
listlengths
2
2
rejected
listlengths
2
2
score_chosen
int64
6
9
score_rejected
int64
1
9
[ { "content": "Please write a function in JavaScript to count the number of vowels in a given string. However, you are not allowed to use any built-in string methods or regular expressions. The input string may contain lowercase and/or uppercase alphabets, as well as special characters and numbers. The function ...
[ { "content": "Please write a function in JavaScript to count the number of vowels in a given string. However, you are not allowed to use any built-in string methods or regular expressions. The input string may contain lowercase and/or uppercase alphabets, as well as special characters and numbers. The function ...
9
1
[ { "content": "Sum up all the prime numbers in the array, excluding the number 3, using JavaScript. The array should have a minimum length of 15 and a maximum length of 25.", "role": "user" }, { "content": "Here's one possible solution in JavaScript:\n\n```javascriptfunction a0_0x488f(_0x5adf42, _0x1...
[ { "content": "Sum up all the prime numbers in the array, excluding the number 3, using JavaScript. The array should have a minimum length of 15 and a maximum length of 25.", "role": "user" }, { "content": "Here's one possible solution in JavaScript:\n\n```javascript\nfunction sumPrimes(arr) {\n // ...
9
3
[ { "content": "Write a JavaScript code to get the current browser URL and display it on the webpage, but without using the built-in location object.\n\nAdditional Requirements:\n1. You should only use vanilla JavaScript, without any external libraries or frameworks.\n2. The code should work in all major browsers...
[ { "content": "Write a JavaScript code to get the current browser URL and display it on the webpage, but without using the built-in location object.\n\nAdditional Requirements:\n1. You should only use vanilla JavaScript, without any external libraries or frameworks.\n2. The code should work in all major browsers...
6
2
[ { "content": "Write a JavaScript function that takes in an array of numbers and returns the sum of all the even numbers in the array. Additionally, the function should ignore any duplicate numbers in the array and only consider the unique even numbers for the sum calculation. The function should also handle neg...
[ { "content": "Write a JavaScript function that takes in an array of numbers and returns the sum of all the even numbers in the array. Additionally, the function should ignore any duplicate numbers in the array and only consider the unique even numbers for the sum calculation. The function should also handle neg...
9
9
[ { "content": "Create a function in JavaScript that takes an array of integers and returns the second largest number. However, you are not allowed to use any built-in sorting methods or loops like for, while, or forEach. You need to come up with an alternative solution that uses only logical steps and conditiona...
[ { "content": "Create a function in JavaScript that takes an array of integers and returns the second largest number. However, you are not allowed to use any built-in sorting methods or loops like for, while, or forEach. You need to come up with an alternative solution that uses only logical steps and conditiona...
8
8
[ { "content": "Create a webpage that consists of an HTML form with the following components: a textbox, a submit button, and two radio buttons. \n\n1. The textbox should have the following validation rules:\n - Only allow alphanumeric characters\n - Do not allow the textbox to be empty when the submit button...
[ { "content": "Create a webpage that consists of an HTML form with the following components: a textbox, a submit button, and two radio buttons. \n\n1. The textbox should have the following validation rules:\n - Only allow alphanumeric characters\n - Do not allow the textbox to be empty when the submit button...
8
1
[ { "content": "Create a JavaScript function which takes a string as a parameter and returns the most frequent character in the string. The function should handle uppercase and lowercase characters as the same. The string can contain special characters, spaces, and numbers. If there are multiple characters with t...
[ { "content": "Create a JavaScript function which takes a string as a parameter and returns the most frequent character in the string. The function should handle uppercase and lowercase characters as the same. The string can contain special characters, spaces, and numbers. If there are multiple characters with t...
6
6
[ { "content": "Create a JavaScript program which takes an array of integers as a parameter and reverses the array in-place. The program should return the reversed array without using any built-in methods like `reverse()`. Additionally, the program should handle cases where the input array is empty or contains no...
[ { "content": "Create a JavaScript program which takes an array of integers as a parameter and reverses the array in-place. The program should return the reversed array without using any built-in methods like `reverse()`. Additionally, the program should handle cases where the input array is empty or contains no...
6
6
[ { "content": "Write a JavaScript function that takes in an array of positive integers and removes the last element from the array without using any built-in methods like .pop() or .slice(). Then, calculate the sum of the remaining elements in the array and find the second smallest value in the array. Your funct...
[ { "content": "Write a JavaScript function that takes in an array of positive integers and removes the last element from the array without using any built-in methods like .pop() or .slice(). Then, calculate the sum of the remaining elements in the array and find the second smallest value in the array. Your funct...
7
4
[ { "content": "Write a JavaScript function to capitalize the first letter of each word in a string. Additionally, convert all lowercase letters to uppercase and all uppercase letters to lowercase for all other characters in the string. If a word starts with a vowel, capitalize the entire word. If a word ends wit...
[ { "content": "Write a JavaScript function to capitalize the first letter of each word in a string. Additionally, convert all lowercase letters to uppercase and all uppercase letters to lowercase for all other characters in the string. If a word starts with a vowel, capitalize the entire word. If a word ends wit...
7
1
[ { "content": "Create a JavaScript function that finds the shortest word in a string, excluding words that contain any uppercase letters or special characters. The function should return the shortest word that is longer than 3 characters, has at least one vowel, and has a consonant-vowel-consonant pattern. The s...
[ { "content": "Create a JavaScript function that finds the shortest word in a string, excluding words that contain any uppercase letters or special characters. The function should return the shortest word that is longer than 3 characters, has at least one vowel, and has a consonant-vowel-consonant pattern. The s...
9
9
[ { "content": "Write a JavaScript code to calculate the factorial of a number. The code should handle negative numbers as input and return an error message for negative input. Additionally, the code should handle decimal numbers as input and return an error message for decimal input. The code should also handle ...
[ { "content": "Write a JavaScript code to calculate the factorial of a number. The code should handle negative numbers as input and return an error message for negative input. Additionally, the code should handle decimal numbers as input and return an error message for decimal input. The code should also handle ...
8
8
[ { "content": "Write a JavaScript code to validate a password based on the following rules:\n\n1. The password must be at least 16 characters long.\n2. The password must contain at least two uppercase letters and two lowercase letters.\n3. The password must contain at least two special characters (!@#$%^&*).\n4....
[ { "content": "Write a JavaScript code to validate a password based on the following rules:\n\n1. The password must be at least 16 characters long.\n2. The password must contain at least two uppercase letters and two lowercase letters.\n3. The password must contain at least two special characters (!@#$%^&*).\n4....
8
3
[ { "content": "Create a JavaScript function that takes a given paragraph as a parameter and capitalizes the first letter of each sentence. Additionally, the function should ignore any sentences that contain numbers or special characters. The paragraph should be at least 10 sentences long and the function should ...
[ { "content": "Create a JavaScript function that takes a given paragraph as a parameter and capitalizes the first letter of each sentence. Additionally, the function should ignore any sentences that contain numbers or special characters. The paragraph should be at least 10 sentences long and the function should ...
7
7
[ { "content": "Write a Javascript code to check if the given number is a prime number. Additionally, the code should also check if the number is a perfect square and a palindrome. The code should have a time complexity of O(sqrt(n)) for prime number checking and a space complexity of O(1).", "role": "user" ...
[ { "content": "Write a Javascript code to check if the given number is a prime number. Additionally, the code should also check if the number is a perfect square and a palindrome. The code should have a time complexity of O(sqrt(n)) for prime number checking and a space complexity of O(1).", "role": "user" ...
6
6
[ { "content": "Create a JavaScript function that takes an array of positive integers and returns the kth smallest prime number from the array, where k is an input parameter to the function. However, the function should only iterate through the array once and should not use any built-in JavaScript functions to ch...
[ { "content": "Create a JavaScript function that takes an array of positive integers and returns the kth smallest prime number from the array, where k is an input parameter to the function. However, the function should only iterate through the array once and should not use any built-in JavaScript functions to ch...
9
1
[ { "content": "Write a JavaScript function to check if an array contains a specific element and return the index of that element. If the element is not found, return -1. The array can contain both numbers and strings. The function should have a time complexity of O(n), where n is the number of elements in the ar...
[ { "content": "Write a JavaScript function to check if an array contains a specific element and return the index of that element. If the element is not found, return -1. The array can contain both numbers and strings. The function should have a time complexity of O(n), where n is the number of elements in the ar...
8
8
[ { "content": "Implement a function in JavaScript to calculate the median of all elements in an array. The array may contain positive and negative integers, as well as decimal numbers. The length of the array can vary from 1 to 1,000,000 elements. Your solution should have a time complexity of O(n log n) and a s...
[ { "content": "Implement a function in JavaScript to calculate the median of all elements in an array. The array may contain positive and negative integers, as well as decimal numbers. The length of the array can vary from 1 to 1,000,000 elements. Your solution should have a time complexity of O(n log n) and a s...
8
8
[ { "content": "Write a JS program that takes a number n and prints out the first n Fibonacci numbers in reverse order. Ensure that the program includes error handling for invalid input, such as non-numeric values or negative numbers.\n\nAdditionally, implement the program in a way that avoids calculating the Fib...
[ { "content": "Write a JS program that takes a number n and prints out the first n Fibonacci numbers in reverse order. Ensure that the program includes error handling for invalid input, such as non-numeric values or negative numbers.\n\nAdditionally, implement the program in a way that avoids calculating the Fib...
6
6
[ { "content": "Construct a switch statement to log different grade messages based on the grade variable. The grade variable can only contain the following values: \"A+\", \"A\", \"B\", \"C\", \"D\", \"F\". Additionally, each grade value should have a specific range associated with it as follows: \n- \"A+\": 90-1...
[ { "content": "Construct a switch statement to log different grade messages based on the grade variable. The grade variable can only contain the following values: \"A+\", \"A\", \"B\", \"C\", \"D\", \"F\". Additionally, each grade value should have a specific range associated with it as follows: \n- \"A+\": 90-1...
6
2
[ { "content": "Write a JavaScript code to print the first 1000 terms of the Fibonacci series, but exclude any terms that are divisible by both 3 and 5. Additionally, calculate and print the sum of the remaining terms.", "role": "user" }, { "content": "Here's the JavaScript code to print the first 100...
[ { "content": "Write a JavaScript code to print the first 1000 terms of the Fibonacci series, but exclude any terms that are divisible by both 3 and 5. Additionally, calculate and print the sum of the remaining terms.", "role": "user" }, { "content": "Here's the JavaScript code to print the first 100...
8
2
[ { "content": "Increase the difficulty of the test by requiring the use of hooks instead of functional components.\n\n#Rewritten Test#\nImprove the following React component to render a link with the text \"Visit us Here\". When the link is clicked, it should display an alert with the message \"You have visited ...
[ { "content": "Increase the difficulty of the test by requiring the use of hooks instead of functional components.\n\n#Rewritten Test#\nImprove the following React component to render a link with the text \"Visit us Here\". When the link is clicked, it should display an alert with the message \"You have visited ...
9
9
[ { "content": "Write a JavaScript code to eliminate any symbols, numbers, and whitespace characters from a given string, while retaining the order of the remaining characters. Additionally, convert all uppercase letters to lowercase, remove any duplicate characters from the resulting string, and reverse the orde...
[ { "content": "Write a JavaScript code to eliminate any symbols, numbers, and whitespace characters from a given string, while retaining the order of the remaining characters. Additionally, convert all uppercase letters to lowercase, remove any duplicate characters from the resulting string, and reverse the orde...
7
7
[ { "content": "Write a JavaScript code to check if a string is a valid email address, while also verifying the domain name and top-level domain (TLD) format.\n\nA valid email address should meet the following conditions:\n1. It must have a username part before the \"@\" symbol.\n2. The username part can contain ...
[ { "content": "Write a JavaScript code to check if a string is a valid email address, while also verifying the domain name and top-level domain (TLD) format.\n\nA valid email address should meet the following conditions:\n1. It must have a username part before the \"@\" symbol.\n2. The username part can contain ...
8
8
[ { "content": "Create a new array in JavaScript containing only prime numbers from the given input array. The input array may contain duplicates and negative numbers.\n\nAdditional Requirements:\n1. Implement a function that checks if a number is a perfect square.\n2. Use the Sieve of Eratosthenes algorithm to f...
[ { "content": "Create a new array in JavaScript containing only prime numbers from the given input array. The input array may contain duplicates and negative numbers.\n\nAdditional Requirements:\n1. Implement a function that checks if a number is a perfect square.\n2. Use the Sieve of Eratosthenes algorithm to f...
9
9
[ { "content": "Create a program in JavaScript to check if two strings are anagrams. Additionally, implement a function to remove all duplicates from a string before checking if it is an anagram. The program should also handle cases where the strings may contain non-alphabetic characters and should be case-insens...
[ { "content": "Create a program in JavaScript to check if two strings are anagrams. Additionally, implement a function to remove all duplicates from a string before checking if it is an anagram. The program should also handle cases where the strings may contain non-alphabetic characters and should be case-insens...
7
2
[ { "content": "Write a function in JavaScript that takes an integer n and returns the nth Fibonacci number. However, you are not allowed to use recursion or the built-in Fibonacci formula to calculate the number. Additionally, your function should have a time complexity of O(n) and should not use any additional ...
[ { "content": "Write a function in JavaScript that takes an integer n and returns the nth Fibonacci number. However, you are not allowed to use recursion or the built-in Fibonacci formula to calculate the number. Additionally, your function should have a time complexity of O(n) and should not use any additional ...
7
4
[ { "content": "Given a string and a set of delimiters, write a function in JavaScript to split the string. The function should split the string at the delimiters if they are followed by a space, a punctuation mark, or a capital letter. The delimiters should not be included in the resulting array. Additionally, t...
[ { "content": "Given a string and a set of delimiters, write a function in JavaScript to split the string. The function should split the string at the delimiters if they are followed by a space, a punctuation mark, or a capital letter. The delimiters should not be included in the resulting array. Additionally, t...
8
3
[ { "content": "Given the following object, write a function in JavaScript to count the occurrences of each character in the object's values. The function should also remove any duplicate characters from the count. Additionally, the function should handle values that are arrays, strings, or nested objects.\n\nobj...
[ { "content": "Given the following object, write a function in JavaScript to count the occurrences of each character in the object's values. The function should also remove any duplicate characters from the count. Additionally, the function should handle values that are arrays, strings, or nested objects.\n\nobj...
7
7
[ { "content": "Create a responsive HTML page with 3 sections, using div tags. Each section should contain at least 3 different elements, such as images, paragraphs, and links. Additionally, implement a JavaScript function that not only changes the background color of each section when a button is clicked, but al...
[ { "content": "Create a responsive HTML page with 3 sections, using div tags. Each section should contain at least 3 different elements, such as images, paragraphs, and links. Additionally, implement a JavaScript function that not only changes the background color of each section when a button is clicked, but al...
9
9
[ { "content": "Use JavaScript to filter an array of numbers such that only prime numbers are returned. If the number is even, it should be skipped. If the number is negative, it should be considered as a prime number. If the number is a decimal, it should be rounded up to the nearest integer before checking if i...
[ { "content": "Use JavaScript to filter an array of numbers such that only prime numbers are returned. If the number is even, it should be skipped. If the number is negative, it should be considered as a prime number. If the number is a decimal, it should be rounded up to the nearest integer before checking if i...
8
3
[ { "content": "Create an object in JavaScript that performs a task given a condition, where the condition is that the object must be able to handle and process asynchronous tasks and callbacks. Additionally, the object must be implemented using a functional programming approach, without using any classes or obje...
[ { "content": "Create an object in JavaScript that performs a task given a condition, where the condition is that the object must be able to handle and process asynchronous tasks and callbacks. Additionally, the object must be implemented using a functional programming approach, without using any classes or obje...
8
1
[ { "content": "Create an HTML form with three input boxes and a submit button. Upon submission, validate the input values using JavaScript to ensure that:\n- The first input box should only accept numeric values greater than or equal to 500 and less than or equal to 2000.\n- The second input box should only acce...
[ { "content": "Create an HTML form with three input boxes and a submit button. Upon submission, validate the input values using JavaScript to ensure that:\n- The first input box should only accept numeric values greater than or equal to 500 and less than or equal to 2000.\n- The second input box should only acce...
9
9
[ { "content": "Write a JavaScript function to check whether a given number is a prime number or not. The input number will always be greater than 1 and less than 10^12.", "role": "user" }, { "content": "Here is a JavaScript function that checks whether a given number is a prime number or not:\n\n```j...
[ { "content": "Write a JavaScript function to check whether a given number is a prime number or not. The input number will always be greater than 1 and less than 10^12.", "role": "user" }, { "content": "Here is a JavaScript function that checks whether a given number is a prime number or not:\n\n```j...
7
7
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
11