I need help these javascript exericses:

Input: A text string, using prompt.
Output: Either "Valid name" or "Invalid name", depending on whether the input names fit the required format, which is
Last name,first name, middle initial
where neither of the names have more than 15 characters.

Function : counter
Parameter: an array of numbers
Returns: the numbers of negative elements, zeros, and values greater than zero in the given array.

Note: you must use a switch statement in the function

Thank you for posting.

However, you are not likely to get the kind of answer you are expecting unless you post some of your solutions, or be specific about where you have your difficulties.

Universities and colleges have very strict rules about plagiary and you do not want to be part of an investigation.

To solve the first exercise of validating a name format in JavaScript, you can follow these steps:

1. Prompt the user to enter the name string using the `prompt` function.
2. Split the name string into three parts: last name, first name, and middle initial. You can use the `split` method to split the name string by comma (`,`) and assign the parts to separate variables.
3. Check the length of each name part using the `length` property. If any of the name parts have more than 15 characters, the name is invalid.
4. Use an `if` condition to check if all name parts are valid and return "Valid name" if true, or "Invalid name" if false.

Here's an example implementation for the name validation function:

```javascript
function validateName() {
var nameString = prompt("Enter the name in the format: Last name, First name, Middle initial");

var nameParts = nameString.split(",");
var lastName = nameParts[0].trim();
var firstName = nameParts[1].trim();
var middleInitial = nameParts[2].trim();

if (lastName.length <= 15 && firstName.length <= 15 && middleInitial.length <= 15) {
return "Valid name";
} else {
return "Invalid name";
}
}

console.log(validateName());
```

To solve the second exercise of counting the number of negative elements, zeros, and values greater than zero in an array using a switch statement, you can follow these steps:

1. Write a function named `counter` that takes an array of numbers as a parameter.
2. Initialize three variables to keep track of the count for each category: `negCount` for negative numbers, `zeroCount` for zeros, and `posCount` for positive numbers. Set all counts to 0 initially.
3. Use a `for` loop to iterate through each element in the array.
4. Inside the loop, use a `switch` statement to check the value of the current element:
- If it is less than 0, increment `negCount` by 1.
- If it is equal to 0, increment `zeroCount` by 1.
- If it is greater than 0, increment `posCount` by 1.
5. Finally, return an object with the count for each category.

Here's an example implementation for the counter function:

```javascript
function counter(numbers) {
var negCount = 0;
var zeroCount = 0;
var posCount = 0;

for (var i = 0; i < numbers.length; i++) {
switch (true) {
case numbers[i] < 0:
negCount++;
break;
case numbers[i] === 0:
zeroCount++;
break;
case numbers[i] > 0:
posCount++;
break;
}
}

return {
negative: negCount,
zero: zeroCount,
positive: posCount
};
}

var numbersArray = [-5, 0, 3, 5, -2, 7, 0, -1];
console.log(counter(numbersArray));
```

The result will be an object with the count of negative numbers, zeros, and positive numbers in the provided array.