// AACR2 TO RDA CONVERTER (EXCERPT)
// Drop this into a Code Academy scratch pad to give it a try
// @orangeaurochs
// The function expand_abbr expands AACR2 abbreviations.
// It takes the contents of a physical description and looks for specific abbreviations to expand, e.g. "p." to "pages".
// It takes one parameter- the AACR2 contents- and returns the expanded RDA version.
// It uses string.replace which can be used in a similar way to string.length, except that string.replace acts like a function and can take two parameters: the string to look for, and a string to replace it with.
var expand_abbr = function (contents) {
contents = contents.replace("p.", "pages");
contents = contents.replace("ill.", "illustrations");
return contents;
}
// The following few lines can be used to test the code above.
// aacr is the contents of an AACR2 physical description
// rda is the contents of an RDA physical description
var aacr = "100 p. : ill. ; 25 cm.";
var rda = expand_abbr (aacr);
console.log(aacr + " would be written as " + rda + " in RDA.");
Comments (0)
You don't have permission to comment on this page.