Can someone please help me with this javascript - Javascript -
do at least 10 of the following questions below
-----------------------------------------------------------------------------------
Create an HTML file that takes in input and carries out
of the following functions and manipulates the DOM to show the
outcome.
Please put the question itself as a comment above each
answer.
Use either JavaScript, jQuery, or both (but know the
difference!).
-----------------------------------------------------------------------------------
1. Fibonacci
Define function: fib(n)
Return the nth number in the fibonacci sequence.
2. Bubble Sort
Define function: bubbleSort(numArray)
Use the bubble sort algorithm to sort the array.
Return the sorted array.
3. Reverse String
Define function: reverseStr(someStr)
Reverse and return the String.
4. Factorial
Define function: factorial(someNum)
Use recursion to compute and return the factorial of someNum.
5. Substring
Define function substring(someStr, length, offset)
Return the substring contained between offset and (offset + length)
inclusively.
If incorrect input is entered, use the alert function and describe
why the input was incorrect.
6. Even Number
Define function: isEven(someNum)
Return true if even, false if odd.
Do not use % operator.
7. Palindrome
Define function isPalindrome(someStr)
Return true if someStr is a palindrome, otherwise return false
8. Shapes
Define function: printShape(shape, height, character)
shape is a String and is either "Square", "Triangle",
"Diamond".
height is a Number and is the height of the shape. Assume the
number is odd.
character is a String that represents the contents of the shape.
Assume this String contains just one character.
Use a switch statement to determine which shape was passed
in.
Use the console.log function to print the desired shape.
Example for printShape("Square", 3, "%");
%%%
%%%
%%%
Example for printShape("Triangle", 3, "$");
$
$$
$$$
Example for printShape("Diamond", 5, "*");
*
***
*****
***
*
9. Object literal
Define function traverseObject(someObj)
Print every property and it's value.
10. Delete Element
Define function deleteElement(someArr)
Print length
Delete the third element in the array.
Print length
The lengths should be the same.
11. Splice Element
Define function spliceElement(someArr)
Print length
Splice the third element in the array.
Print length
The lengths should be one less than the original length.
12. Defining an object using a constructor
Define a function Person(name, age)
The following line should set a Person object to the variable
john:
var john = new Person("John", 30);
13. Defining an object using an object literal
Define function getPerson(name, age)
The following line should set a Person object to the variable
john:
var john = getPerson("John", 30);
14. Display the current time on the top right of your HTML
page,
updating every second
15. Descending order
Your task is to make a function that can take any
non-negative
integer as a argument and return it with its digits in
descending
order. Essentially, rearrange the digits to create the highest
possible number.
Thank you so much for helping!!
1. Fibonacci
Define function: fib(n)
Return the nth number in the fibonacci sequence.
<html>
<script type="text/javascript">
function fib(n)
{
var n1= 0;
var n2 = 1;
var val;
document.write(var1+"<br />");
document.write(var2+"<br />");
for(var i=3; i <= n;i++)
{
val = n1 + n2
n1 = n2
n2 = val
document.write(val+"<br />");
}
}
var no = prompt(" Enter the limit to generate fibonacci
no",0);
fib( no);
</script>
</html>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2. Bubble Sort
Define function: bubbleSort(numArray)
Use the bubble sort algorithm to sort the array.
Return the sorted array.
<html>
<script type="text/javascript">
function swap(arr, Index1, Index2){
var temp = arr[Index1];
arr[Index1] = arr[Index2];
arr[Index2] = temp;
}
function bubbleSort(arr){
var len = arr.length,
i, j, stop;
for (i=0; i < len; i++){
for (j=0, stop=len-i; j < stop; j++){
if (arr[j] > arr[j+1]){
swap(arr, j, j+1);
}
}
}
document.write(arr+"<br />");
}
bubbleSort([3, 0, 2, -2, -1, 4, 1]);
</script>
</html>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3. Reverse String
Define function: reverseStr(someStr)
Reverse and return the String.
<html>
<script type="text/javascript">
function reverseStr(str) {
var splitString = str.split("");
var reverseArray = splitString.reverse();
var joinArray = reverseArray.join("");
document.write(joinArray+"<br />");
}
reverseStr("hello");
</script>
</html>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4. Factorial
Define function: factorial(someNum)
Use recursion to compute and return the factorial of someNum.
<html>
<script type="text/javascript">
function factorial(n){
var i, fact;
fact=1;
for(i=1; i<=n; i++)
{
fact= fact*i;
}
document.write(fact+"<br />");
}
factorial(5)
</script>
</html>
Can someone please help me with this javascript - Javascript - do at least 10 of...
CODE THE FOLLOWING FUNCTIONS IN JAVASCRIPT (USE OF THE
ABOVE MENTIONED IN BUILT FUNCTIONS IS NOT ALLOWED)
Write a function that accepts an array as argument. The function
should loop through the array elements and accumulate the sum of
ASCII value of each character in element and return the total. For
example: function([‘A’, ‘bc’, 12]); // returns 361 which is the sum
of 65 + 98 + 99 + 49 + 50
Write a function that accepts two arguments (a...
In python, please help me fill in these functions given their limitations. Please use for loops. def palindrome(x): """ For a given string, determine if the string is a palindrome. (The same forward and back) Input: String of any size (including empty) Return: Boolean (True if palindrome, False otherwise) Limitation: You must use a loop. Only function allowed to be used is len (if needed). Cannot use "in" besides "for var in container" """ pass def getCount(char, strng): """ Get...
Can someone please help, third time I'm asking. I need a basic javascript with no push or splice command. Please don't post a picture of the code,because my vision is poor and I won't be able to see it. Also, I need breakdown of what's in HTMLand what' s in javascript. All requirements are below. Thanks for your help. This is a 2 part assignment, but both parts can be completed in one program. Also, please follow ALL Required Programming...
Code the following function in JAVASCRIPT (Use of the given
list of inbuilt functions is not allowed)
Write a function that searches the string (passed
as first argument) for the character (passed as second argument)
and changes the case for all instances of that char found in
string. The function should return the new string as shown in
example below: function(‘abRA’, ‘a’) // returns
‘AbRa’
Assignment-2(2).pdf + х A file:///C:/Users/bhati/OneDrive/Desktop/Assignment-2(2).pdf 5 of 6 O + Fit to page IL Page...
IT Review JAVASCRIPT (Can someone please help me answer the below questions. It would be nice if you add comments explaining what you are doing? If unable to add comments the answer would be fantastic. Thank you. Given the following function definition: function percent(x) { return x / 100; } Which of the following statements correctly calls the percent function: percent(10); percent: 10; percent(); percent = 10; Indicate whether each of the following evaluates to true or false, given...
C Programming Language only please. Your help is greatly
appreciated. Will give thumbs up for quality work.
Lab 8 (this is to be turned in) Palindrome is a string that is the same as backwards or forwards “otto” “ababa” “noon” “ababbbbaba” In this lab we will work with strings (so we will be using character arrays). 1. Write a program that reads two strings strl and str2 from the keyboard 2. Print both strings 3. Write a function computeLength and...
Can someone help me with the writing of this code please? public static int promptInt(Scanner input, String prompt, int min, int max) { return 0; //TODO replace } /** * Returns the index within arr of the first occurrence of the specified character. * If arr is null or 0 length then return -1. For all arrays, don't assume a length * but use the array .length attribute. * @param arr The array to look...
Can you help me make these two methods listed below work? I have code written but it is not working. I would appreciate any advice or help. Function "isAPalidrome" accepts an array of characters and returns an integer. You must use pointer operations only, no arrays. This function should return 1 (true) if the parameter 'string' is a palindrome, or 0 (false) if 'string' is not a palindrome. A palindrome is a sequence of characters which when reversed, is the...
In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...
Please use Visual Studio! Let me know if you need anything else <3 #include <stdio.h> #include <string.h> #pragma warning(disable : 4996) // compiler directive for Visual Studio only // Read before you start: // You are given a partially complete program. Complete the functions in order for this program to work successfully. // All instructions are given above the required functions, please read them and follow them carefully. // You shoud not modify the function return types or parameters. //...