Assignment 11 Development of solution
for Bidding Problem
Overall plan
1. Find biddingSequence in web page
2. Extract contents of span
3. Translate to formatted bidding
4. Change HTML of span
Engineers tackle big problems by breaking into
small problems. Linear. Step by step.
Engineers tackle hard problem by simplifying
them then adding on to the solution of the
simpler problem. The onion approach.
Plan - lets just tackle step 3
Plan - this jQuery stuff is confusing, lets just
treat this as a string processing problem.
Just like the last assignment, we can use the
FB console for output. Later, we will think
about getting this working with HTML.
The notes give us a finished example we can work with.
1h 1s 1N 2d
and translate this into
1
– 1
,
1N –
2
My onion approach has me working on only the string translation, so my
task is
Input: 1h 1s 1N 2d
Output:
1
– 1
,
1N –
2
The notes for the assignment further break down this part:
Suggested steps for completing the assignment.
1. Parse the input and add the basic punctuation (the dashes and commas).
2. Sharpen up the punctionation
3. Add the images for the suits.
Step 1a - parse input
var str ="1h 1s 1N 2d"
var bids = str.trim().split(' ');
console.log(bids);
Step 1b - add punctuation. We will want to create a new string, result,
var result = "";
for(var index = 0; index < bids.length; index++ ) {
result += bids[index] + ' ';
}
We are rolling now.
Add punctuation
for(var index = 0; index < bids.length; index++ ) {
result += bids[index] + ' ';