Welcome to BHS Computer Science. If you are a student in the class, the first thing you need to do (and which we should have done in class) is set up your GitHub account.
Once you have a GitHub account, click “Log in to GitHub” below to proceed. Or you can click “Use anonymously” to play with the environment but you will not be able to save your work or submit assignments. (You can always log in later by clicking the at the top of the page.)
If you don’t have a GitHub account yet, please create one and then log in here for further instructions.
Congratulations! You have successfully connected this app to GitHub. However you are not yet a member of the GitHub organization for this class, something Mr. Seibel needs to set up for you.
This is your GitHub profile URL:
Click the clipboard icon to copy it and then submit it at this form so he can add you.
Congratulations! You have successfully connected this app to GitHub. And it looks like you have an invitation to join the GitHub organization for this class. You need to accept that invitation before you can proceed. The invite should be sent to whatever email you used when you created your GitHub account.
I see you are logged into GitHub and a member of the berkeley-high-cs GitHub organization. However there seems to have been some problem finishing the setup for your account. Please let Mr. Seibel know.
This is a tool for the BHS Computer Science class at Berkeley High School. It is intended to provide a simple environment for experimenting with Javascript without all the complexities of a full development environment such as ReplIt or Glitch which we may use later in the year.
It is also designed to take advantage of the browser’s ability to run Javascript natively. It does not need access to a server to run code making in extremely responsive even if the Wifi is flaking out.
Finally, under the covers it is saving work to a GitHub repository in a very simplified workflow that does not depend on immediately learning any git commands. Code written in this environment for each assignment is saved to a directory and branch specific to that assignment each time it is saved. Thus when the assignment is done, it is easy to go to GitHub and create a PR containing just the work on that assignment which can then be commented on and worked on further before it is turned in and merged to main.
You're all set! You don't need to worry about this yet but we have successfully created a GitHub repository for your work:
You can get to it any time by clicking on your GitHub username at the top-right of the screen.
This assessment consists of
functions you need to write
involving primarily string expressions. It is a
closed book assessment. You should stay on this tab until you
are done and there should be no talking. This assessment is about how
much you understand. There are no automatic tests but you can
use the REPL to test things yourself. For example, after defining the
firstHalf
function and pressing the blue arrow, you can
type firstHalf('foobar')
in the repl and hit return to
see if it evaluates to the expected 'foo'
.
You can move through the questions with the arrows at the upper right
next to the 1 of indicator so if
you're not sure how to write one function move on to another one and
come back if you have time at the end. I want to see how much you do
know. Note: you can also click on
thingsLikeThis
in these instructions and the questions to
copy them to the clipboard to avoid spelling mistakes. (I.e. click to
copy and then ⌘-v to paste wherever you want.)
Some of these functions will be much easier (even trivial) to write if
you use the indexOf
method I introduced on the latest
string functions assignment. To refresh your memory,
indexOf
takes a single argument, which should be a
string, and returns the index at which the sting argument first
occurres in the string on which the method is called. It returns -1 if
the argument string is not found. For instance if s
is
our old standby "foobar"
then
s.indexOf("bar")
is 3
.
When you are done, please click on your Github username above
and submit a GitHub pull request of the branch
and request me as a reviewer. Doing
this correctly is part of the assessment.
If you are unsure how to request a review, please ask for help!
Write a function named firstHalf
that takes a
single string argument and returns the first half of the string.
(If the string has an odd number of characters it doesn't matter
whether or not you include the extra character.) For instance
the first half of 'foobar'
is
'foo'
but if the argument was
'fooquux'
then either 'foo'
or
'fooq'
would be acceptable return values.
Write a function named secondHalf
that takes a
single string argument and returns the second half of the
string. (If the string has an odd number of characters it
doesn't matter whether or not you include the extra character.)
For instance the second half of 'foobar'
is
'bar'
but if the argument was
'fooquux'
then either 'quux'
or
'uux'
would be acceptable return values. For
maximum style points write this function and
firstHalf
so that
firstHalf(s) + secondHalf(s)
gives you back
s
.
Write a function named upDown
that takes a single
string argument and returns a string consisting of the original
string all in upper case concatenated (“smooshed together”) with
the string all in lower case. E.g. called with
'foo'
it should return 'FOOfoo'
.
Write a function named firstFewEveryOther
that
takes a single string argument that is at least five characters
long and returns a string consisting of just the first, third,
and fifth characters of the argument string. E.g. called with
'foobar'
it should return 'foa'
.
Write a function named upDownLastCharacter
that
takes a single string argument that is at least one character
long and returns a string consisting of two characters, the
uppercase version of the last character of the argument string
and the lowercase version of that same character. E.g. called
with 'foo'
it should return 'Oo'
.
Write a function named firstAndLast
that takes a
single string argument (which will be at least two characters
long) and returns a string consisting of just the first and last
characters of the string.
Write a function named swapFrontAndBack
that takes
a single string argument and returns a string consisting of the
second half of the original string followed by the first half.
If the string is an odd number of characters it doesn’t matter
whether the extra character goes with the front or the back.
As you should recall from the Pig Latin assignment, the rules of simple Pig Latin say that a word is translated into Pig Latin by taking everything up to (but not including) the first vowel and moving it to the end of word and then adding “ay” to the end.
Write a function named simplePigLatin
that takes
two arguments, a string containing a single word and a number
indicating the index of the first vowel in the word, and returns
the word translated into Pig Latin.
Write a function named randomCharacter
that takes a
single string argument and returns a random character from the
string. For this function you will need to use the
rand
function defined at the top of the starter code.
Write a function named randomCharacterUpDown
that
takes a single string argument and returns a string consisting
of a single random character repeated twice, once in upper case
and then in lower case. For this function you will need to use
the rand
function defined at the top of the starter
code.
Write a function named isAllUpperCase
that takes a
single string argument and returns a boolean indicating whether
the string is all upper case.
Write a function named sameIgnoringCase
that takes
two string arguments and returns a boolean indicating whether
they are the same string if you ignore case differences.
Write a function named firstName
that takes a
single string argument which will consist of a full name in the
form first name, a space, and the last name and returns a string
containing just the first name. You will probably want to use
the indexOf
method.
Write a function named lastName
that takes a single
string argument which will consist of a full name in the form
first name, a space, and the last name and returns a string
containing just the last name. You will probably want to use the
indexOf
method.
Write a function named initials
that takes a single
string argument which will consist of a full name in the form
first name, a space, and the last name and returns a string
containing the person's initials, i.e. the first letter of their
first name followed by the first letter of their last name. You
will probably want to use the indexOf
method.