In the repository, create the following js file.
// sort.js
var number = [19, 3, 81, 1, 24, 21];
console.log(number);
Once you have created the file, push it to a remote branch. Learn how to push to a remote repository.
Now, we'll walk through how to modify a development branch:1. Create a branch
First create a branch to work on called "add-sort-func" to sort an array.
$ git checkout -b add-sort-func
Learn how to create a branch.
2. Modify the file and commit
Modify the file as follows.
// sort.js
var sortNumber = function (number) {
number.sort(function (a, b) {
if (a == b) {
return 0;
}
return a < b ? -1 : 1;
});
};
var number = [19, 3, 81, 1, 24, 21];
sortNumber(number);
console.log(number);
Commit when the modification is completed.
$ git add sort.js
$ git commit -m "<commit_message>"
3. Push the modified branch
When a commit is complete, push it to a remote branch.
$ git push origin add-sort-func