this is a collection of mini-JavaScript programs that perform a number of small computations.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
General Requirements
-
Write a function in JavaScript that will receive a string as a parameter and then perform the following:
You don’t have to prompt for a string. Simply assign a string to a variable in your code as your starting point to use as an argument for your function.
If the first and last characters of the string are the same (ignoring case), the function will return the string in reverse order. Otherwise, the function will return the string with the first and last letters removed. Example: “Triscuit” returns “tiucsirT” but “Cracker” returns “racke”.
Resources: W3Schools: https://www.w3schools.com/js/js_string_methods.asp MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
-
Write a function in JavaScript that will return the sum of the longest streak of consecutive increasing numbers within an array.
If there are no consecutive numbers in the array, the function will return zero. If there are multiple instances of the same number of consecutive numbers (increasing by 1) in the array, the function will return the largest sum calculated between all instances. Examples: [1, 2, 3, 6, 9, 34, 2, 6] would return 6 (1+2+3) [3, 2, 7, 5, 6, 7, 3, 8, 9, 10, 23, 2, 1, 2, 3] would return 27 (8+9+10) [100, 101, 102, 3, 4, 5, 6, 9] would return 18 (3+4+5+6) Resources:
W3Schools: https://www.w3schools.com/js/js_arrays.asp MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array -
Write a JavaScript program to calculate the number of weeks, days, hours, minutes and seconds left until midnight on your birthday.
The script does not have to prompt for your birthdate. Simply assign it to a variable and start from there. Ex: var myNextBirthday = …your code here Expected sample output (console.log()): There are 35 weeks, 3 days, 13 hours, 25 minutes, and 12 seconds until my next birthday! Resources:
MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date W3Schools: https://www.w3schools.com/js/js_dates.asp -
Write a JavaScript program to iterate through an array of ten(10) positive randomly generated numbers. Each number will then be checked to see if it’s a prime number.
Sample Expected output (console.log()). 23-yes, 15-no, 22-no, 124-no, 11-yes, 9-no, 2-yes, 13-yes, 5-yes, 1-no
-
Instructions
Don’t forget that a live in-person demonstration of your code is part of this assignment. You will need to show your code to the instructor in class on the due date while going through an evaluation of your code’s functionality. Part of the assessment will include your ability to speak about the code you wrote, even if it doesn’t completely work or do what you expect.
This section should list any major frameworks/libraries used to bootstrap your project. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
This is an example of how to list things you need to use the software and how to install them.
- npm
npm install npm@latest -g
Below is an example of how you can instruct your audience on installing and setting up your app. This template doesn't rely on any external dependencies or services.
- Get a free API Key at https://example.com
- Clone the repo
git clone https://github.com/your_username_/Project-Name.git
- Install NPM packages
npm install
- Enter your API in
config.js
const API_KEY = 'ENTER YOUR API';
Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources.
For more examples, please refer to the Documentation
- Add Changelog
- Add back to top links
- Add Additional Templates w/ Examples
- Add "components" document to easily copy & paste sections of the readme
- Multi-language Support
- Chinese
- Spanish
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Your Name - @your_twitter - [email protected]
Project Link: https://github.com/your_username/repo_name
Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!